@@ -14,6 +14,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
1414 }
1515
1616 $exeName = $IsWindows ? ' testexe.exe' : ' testexe'
17+ $exePath = @ (Get-Command $exeName - Type Application)[0 ].Path
1718
1819 $errorActionPrefTestCases = @ (
1920 @ { ErrorActionPref = ' Stop' }
@@ -43,7 +44,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
4344
4445 $error.Count | Should - Be 1
4546 $error [0 ].FullyQualifiedErrorId | Should - BeExactly ' ProgramExitedWithNonZeroCode'
46- $error [0 ].TargetObject | Should - BeExactly $exeName
47+ $error [0 ].TargetObject | Should - BeExactly $exePath
4748 }
4849
4950 It ' Non-zero exit code outputs a non-teminating error for $ErrorActionPreference = '' Continue'' ' {
@@ -52,7 +53,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
5253 $stderr = testexe - returncode 1 2>&1
5354
5455 $error [0 ].FullyQualifiedErrorId | Should - BeExactly ' ProgramExitedWithNonZeroCode'
55- $error [0 ].TargetObject | Should - BeExactly $exeName
56+ $error [0 ].TargetObject | Should - BeExactly $exePath
5657 $stderr [1 ].Exception.Message | Should - BeExactly " Program `" $exeName `" ended with non-zero exit code: 1."
5758 }
5859
@@ -65,7 +66,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
6566 $stderr = testexe - returncode 1 2>&1
6667
6768 $error [0 ].FullyQualifiedErrorId | Should - BeExactly ' ProgramExitedWithNonZeroCode'
68- $error [0 ].TargetObject | Should - BeExactly $exeName
69+ $error [0 ].TargetObject | Should - BeExactly $exePath
6970 $stderr [1 ].Exception.Message | Should - BeExactly " Program `" $exeName `" ended with non-zero exit code: 1."
7071 }
7172
@@ -76,7 +77,7 @@ Describe 'Native command error handling tests' -Tags 'CI' {
7677
7778 $error.Count | Should - Be 1
7879 $error [0 ].FullyQualifiedErrorId | Should - BeExactly ' ProgramExitedWithNonZeroCode'
79- $error [0 ].TargetObject | Should - BeExactly $exeName
80+ $error [0 ].TargetObject | Should - BeExactly $exePath
8081 }
8182
8283 It ' Non-zero exit code does not generates an error record for $ErrorActionPreference = '' Ignore'' ' {
0 commit comments