diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 950b6c0c..f99927f2 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -920,10 +920,17 @@ jobs: # Run the command following `Invoke-Program`. # If that command returns a non-zero exit code, return the same exit code from this script. + # When there is no exit code (e.g. program failed to launch), we fall back to $?. function Invoke-Program($Executable) { + $global:LASTEXITCODE = $null & $Executable @args - if ($LastExitCode -ne 0) { - exit $LastExitCode + $ok = $? + if ($null -eq $LASTEXITCODE) { + if (-not $ok) { + exit 1 + } + } elseif ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE } } Invoke-Program swift --version