Don't clear the exit code from the Finally block
It turns out that the Finally block does not see the exit code from the `exit` call that triggered it, but from an earlier state. And it seems that actions take in the Finally block other than `exit` will not affect the $LastErrorCode set by the `exit` that triggered the Finally block. Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
parent
c7109494fe
commit
080d9df63e
|
@ -1012,9 +1012,6 @@ Catch [Exception] {
|
||||||
Throw $_
|
Throw $_
|
||||||
}
|
}
|
||||||
Finally {
|
Finally {
|
||||||
# Preserve the LastExitCode of the tests
|
|
||||||
$tmpLastExitCode = $LastExitCode
|
|
||||||
|
|
||||||
$ErrorActionPreference="SilentlyContinue"
|
$ErrorActionPreference="SilentlyContinue"
|
||||||
$global:ProgressPreference=$origProgressPreference
|
$global:ProgressPreference=$origProgressPreference
|
||||||
Write-Host -ForegroundColor Green "INFO: Tidying up at end of run"
|
Write-Host -ForegroundColor Green "INFO: Tidying up at end of run"
|
||||||
|
@ -1053,6 +1050,4 @@ Finally {
|
||||||
|
|
||||||
$Dur=New-TimeSpan -Start $StartTime -End $(Get-Date)
|
$Dur=New-TimeSpan -Start $StartTime -End $(Get-Date)
|
||||||
Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n"
|
Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n"
|
||||||
|
|
||||||
exit $tmpLastExitCode
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue