summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobb Kidd <robb@thekidds.org>2020-04-27 15:11:00 -0400
committerRobb Kidd <robb@thekidds.org>2020-04-27 15:11:00 -0400
commit9405540670d6807f811a20b59370345148f7611c (patch)
tree0d9a843ff73c1d86b57a51e26046b2c0aedb161e
parent78a7f44304b443e980d0b791671efd00dec38e5c (diff)
downloadchef-9405540670d6807f811a20b59370345148f7611c.tar.gz
add exitstatus checks after bare commands in PowerShell scripts
Need these so the PowerShell scripts will exit when bare commands fail. Otherwise the build just keeps truckin' and the errors just pile up. Signed-off-by: Robb Kidd <robb@thekidds.org>
-rw-r--r--scripts/bk_tests/bk_run_choco.ps17
-rw-r--r--scripts/bk_tests/bk_win_functional.ps19
-rw-r--r--scripts/bk_tests/bk_win_integration.ps111
-rw-r--r--scripts/bk_tests/bk_win_unit.ps18
4 files changed, 24 insertions, 11 deletions
diff --git a/scripts/bk_tests/bk_run_choco.ps1 b/scripts/bk_tests/bk_run_choco.ps1
index 5360cc4914..cf84b1feb5 100644
--- a/scripts/bk_tests/bk_run_choco.ps1
+++ b/scripts/bk_tests/bk_run_choco.ps1
@@ -7,6 +7,7 @@ choco --version
echo "--- update bundler and rubygems"
ruby -v
+if (-not $?) { throw "Can't run Ruby. Is it installed?" }
$env:RUBYGEMS_VERSION=$(findstr rubygems omnibus_overrides.rb | %{ $_.split(" ")[3] })
$env:BUNDLER_VERSION=$(findstr bundler omnibus_overrides.rb | %{ $_.split(" ")[3] })
@@ -18,14 +19,16 @@ echo $env:RUBYGEMS_VERSION
echo $env:BUNDLER_VERSION
gem update --system $env:RUBYGEMS_VERSION
+if (-not $?) { throw "Unable to update system Rubygems" }
gem --version
gem install bundler -v $env:BUNDLER_VERSION --force --no-document --quiet
+if (-not $?) { throw "Unable to update Bundler" }
bundle --version
echo "--- bundle install"
bundle install --jobs=3 --retry=3 --without omnibus_package docgen chefstyle
+if (-not $?) { throw "Unable to install gem dependencies" }
echo "+++ bundle exec rspec chocolatey_package_spec"
bundle exec rspec spec/functional/resource/chocolatey_package_spec.rb
-
-exit $LASTEXITCODE
+if (-not $?) { throw "Chef chocolatey functional tests failing." }
diff --git a/scripts/bk_tests/bk_win_functional.ps1 b/scripts/bk_tests/bk_win_functional.ps1
index 5bcbfb60c9..90abfe890f 100644
--- a/scripts/bk_tests/bk_win_functional.ps1
+++ b/scripts/bk_tests/bk_win_functional.ps1
@@ -93,6 +93,7 @@ winrm quickconfig -q
echo "--- update bundler and rubygems"
ruby -v
+if (-not $?) { throw "Can't run Ruby. Is it installed?" }
$env:RUBYGEMS_VERSION=$(findstr rubygems omnibus_overrides.rb | %{ $_.split(" ")[3] })
$env:BUNDLER_VERSION=$(findstr bundler omnibus_overrides.rb | %{ $_.split(" ")[3] })
@@ -104,14 +105,16 @@ echo $env:RUBYGEMS_VERSION
echo $env:BUNDLER_VERSION
gem update --system $env:RUBYGEMS_VERSION
+if (-not $?) { throw "Unable to update system Rubygems" }
gem --version
gem install bundler -v $env:BUNDLER_VERSION --force --no-document --quiet
-bundle --version
+if (-not $?) { throw "Unable to update Bundler" }
+bundle --versio
echo "--- bundle install"
bundle install --jobs=3 --retry=3 --without omnibus_package docgen chefstyle
+if (-not $?) { throw "Unable to install gem dependencies" }
echo "+++ bundle exec rake spec:functional"
bundle exec rake spec:functional
-
-exit $LASTEXITCODE
+if (-not $?) { throw "Chef functional specs failing." }
diff --git a/scripts/bk_tests/bk_win_integration.ps1 b/scripts/bk_tests/bk_win_integration.ps1
index 36a6ea2ea9..88d23802cd 100644
--- a/scripts/bk_tests/bk_win_integration.ps1
+++ b/scripts/bk_tests/bk_win_integration.ps1
@@ -2,7 +2,7 @@ echo "--- system details"
$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'
Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize
-# Set-Item -Path Env:Path -Value ($Env:Path + ";C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin")
+# Set-Item -Path Env:Path -Value ($Env:Path + ";C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin")
$Env:Path="C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ruby26\bin;C:\ci-studio-common\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Go\bin;C:\Users\ContainerAdministrator\go\bin"
winrm quickconfig -q
@@ -10,6 +10,7 @@ winrm quickconfig -q
echo "--- update bundler and rubygems"
ruby -v
+if (-not $?) { throw "Can't run Ruby. Is it installed?" }
$env:RUBYGEMS_VERSION=$(findstr rubygems omnibus_overrides.rb | %{ $_.split(" ")[3] })
$env:BUNDLER_VERSION=$(findstr bundler omnibus_overrides.rb | %{ $_.split(" ")[3] })
@@ -21,14 +22,16 @@ echo $env:RUBYGEMS_VERSION
echo $env:BUNDLER_VERSION
gem update --system $env:RUBYGEMS_VERSION
+if (-not $?) { throw "Unable to update system Rubygems" }
gem --version
gem install bundler -v $env:BUNDLER_VERSION --force --no-document --quiet
-bundle --version
+if (-not $?) { throw "Unable to update Bundler" }
+bundle --versio
echo "--- bundle install"
bundle install --jobs=3 --retry=3 --without omnibus_package docgen chefstyle
+if (-not $?) { throw "Unable to install gem dependencies" }
echo "+++ bundle exec rake spec:integration"
bundle exec rake spec:integration
-
-exit $LASTEXITCODE
+if (-not $?) { throw "Chef integration specs failing." }
diff --git a/scripts/bk_tests/bk_win_unit.ps1 b/scripts/bk_tests/bk_win_unit.ps1
index 4e07179a35..2ec313fdd0 100644
--- a/scripts/bk_tests/bk_win_unit.ps1
+++ b/scripts/bk_tests/bk_win_unit.ps1
@@ -5,6 +5,7 @@ Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table
echo "--- update bundler and rubygems"
ruby -v
+if (-not $?) { throw "Can't run Ruby. Is it installed?" }
$env:RUBYGEMS_VERSION=$(findstr rubygems omnibus_overrides.rb | %{ $_.split(" ")[3] })
$env:BUNDLER_VERSION=$(findstr bundler omnibus_overrides.rb | %{ $_.split(" ")[3] })
@@ -16,15 +17,18 @@ echo $env:RUBYGEMS_VERSION
echo $env:BUNDLER_VERSION
gem update --system $env:RUBYGEMS_VERSION
+if (-not $?) { throw "Unable to update system Rubygems" }
gem --version
gem install bundler -v $env:BUNDLER_VERSION --force --no-document --quiet
+if (-not $?) { throw "Unable to update Bundler" }
bundle --version
echo "--- bundle install"
bundle install --jobs=3 --retry=3 --without omnibus_package docgen chefstyle
+if (-not $?) { throw "Unable to install gem dependencies" }
echo "+++ bundle exec rake"
bundle exec rake spec:unit
+if (-not $?) { throw "Chef unit tests failing." }
bundle exec rake component_specs
-
-exit $LASTEXITCODE
+if (-not $?) { throw "Chef component specs failing." }