summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremiah Snapp <jeremiah@chef.io>2022-05-16 16:23:30 -0400
committerJeremiah Snapp <jeremiah@chef.io>2022-05-16 16:23:30 -0400
commit74dc4feef238da5a2fbe822f052c1782f1a5f938 (patch)
treed3453a141daf42dbb24978fb24bc1295ef0c7c32
parent7bc7b485d8ae31365153d8d9dfd1bffba9b526d6 (diff)
downloadchef-74dc4feef238da5a2fbe822f052c1782f1a5f938.tar.gz
Fix omnibus-test.ps1
Use Throw instead of Exit to ensure the CI job fails when a command has a non-zero exit code. Signed-off-by: Jeremiah Snapp <jeremiah@chef.io>
-rw-r--r--omnibus/omnibus-test.ps123
1 files changed, 20 insertions, 3 deletions
diff --git a/omnibus/omnibus-test.ps1 b/omnibus/omnibus-test.ps1
index 7e3488f060..71af497dd1 100644
--- a/omnibus/omnibus-test.ps1
+++ b/omnibus/omnibus-test.ps1
@@ -47,24 +47,34 @@ ForEach ($b in
}
Else {
Write-Output "Error: Could not find $b"
- exit 1
+ Throw 1
}
}
$Env:PATH = "C:\opscode\chef\bin;$Env:PATH"
chef-client --version
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
# Exercise various packaged tools to validate binstub shebangs
& $embedded_bin_dir\ruby --version
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
+
& $embedded_bin_dir\gem.bat --version
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
+
& $embedded_bin_dir\bundle.bat --version
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
+
& $embedded_bin_dir\rspec.bat --version
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
$Env:PATH = "C:\opscode\chef\bin;C:\opscode\chef\embedded\bin;$Env:PATH"
# Test against the vendored chef gem (cd into the output of "gem which chef")
$chefdir = gem which chef
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
+
$chefdir = Split-Path -Path "$chefdir" -Parent
$chefdir = Split-Path -Path "$chefdir" -Parent
Set-Location -Path $chefdir
@@ -79,9 +89,10 @@ $Env:CHEF_LICENSE = "accept-no-persist"
# some tests need winrm configured
winrm quickconfig -quiet
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
bundle
-If ($lastexitcode -ne 0) { Exit $lastexitcode }
+If ($lastexitcode -ne 0) { Throw $lastexitcode }
# buildkite changes the casing of the Path variable to PATH
# It is not clear how or where that happens, but it breaks the choco
@@ -98,11 +109,17 @@ $exit = 0
bundle exec rspec -f progress --profile -- ./spec/unit
If ($lastexitcode -ne 0) { $exit = 1 }
+Write-Output "Last exit code: $lastexitcode"
+Write-Output ""
bundle exec rspec -f progress --profile -- ./spec/functional
If ($lastexitcode -ne 0) { $exit = 1 }
+Write-Output "Last exit code: $lastexitcode"
+Write-Output ""
bundle exec rspec -f progress --profile -- ./spec/integration
If ($lastexitcode -ne 0) { $exit = 1 }
+Write-Output "Last exit code: $lastexitcode"
+Write-Output ""
-Exit $exit
+Throw $exit