diff options
author | Jeremiah Snapp <jeremiah@chef.io> | 2022-05-16 16:23:30 -0400 |
---|---|---|
committer | Jeremiah Snapp <jeremiah@chef.io> | 2022-05-16 16:26:20 -0400 |
commit | f0c75a7f159df4b8d0db8fe69fa33daf4bbd05cb (patch) | |
tree | 548c4fdd66cfeab9ef6a9b68c4548ff368299afa | |
parent | c2d74155a27f80e09a3e0503fd220b863446e68a (diff) | |
download | chef-f0c75a7f159df4b8d0db8fe69fa33daf4bbd05cb.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.ps1 | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/omnibus/omnibus-test.ps1 b/omnibus/omnibus-test.ps1 index 3182ab4e04..9cb2314876 100644 --- a/omnibus/omnibus-test.ps1 +++ b/omnibus/omnibus-test.ps1 @@ -48,24 +48,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 @@ -80,9 +90,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 @@ -99,11 +110,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 |