Browse code

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>

Paul "TBBle" Hampson authored on 2020/11/05 19:33:17
Showing 1 changed files
... ...
@@ -1012,9 +1012,6 @@ Catch [Exception] {
1012 1012
     Throw $_
1013 1013
 }
1014 1014
 Finally {
1015
-    # Preserve the LastExitCode of the tests
1016
-    $tmpLastExitCode = $LastExitCode
1017
-
1018 1015
     $ErrorActionPreference="SilentlyContinue"
1019 1016
     $global:ProgressPreference=$origProgressPreference
1020 1017
     Write-Host  -ForegroundColor Green "INFO: Tidying up at end of run"
... ...
@@ -1053,6 +1050,4 @@ Finally {
1053 1053
 
1054 1054
     $Dur=New-TimeSpan -Start $StartTime -End $(Get-Date)
1055 1055
     Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n"
1056
-
1057
-    exit $tmpLastExitCode
1058 1056
 }