Fix command runtime so StopUpstreamCommandsException doesn't get populated in -ErrorVariable (#10840)

This commit is contained in:
Steve Lee
2019-10-22 16:38:32 -07:00
committed by Andrew
parent 89c66030ba
commit 26c380de6e
2 changed files with 8 additions and 2 deletions
@@ -2381,7 +2381,8 @@ namespace System.Management.Automation
// 913088-2005/06/06
// PipelineStoppedException should not get added to $Error
// 2008/06/25 - narrieta: ExistNestedPromptException should not be added to $error either
if (!(e is HaltCommandException) && !(e is PipelineStoppedException) && !(e is ExitNestedPromptException))
// 2019/10/18 - StopUpstreamCommandsException should not be added either
if (!(e is HaltCommandException) && !(e is PipelineStoppedException) && !(e is ExitNestedPromptException) && !(e is StopUpstreamCommandsException))
{
try
{
@@ -113,7 +113,12 @@ Describe "Select-Object" -Tags "CI" {
$result[0].Size | Should -Be ($orig1 + 1)
$dirObject[0].Size | Should -Be ($orig1 + 1)
$dirObject[$TestLength].Size | Should -Be ($orig2 + 1)
}
}
It "Should not leak 'StopUpstreamCommandsException' internal exception for stopping upstream" {
1,2 | Select-Object -First 1 -ErrorVariable err
$err | Should -BeNullOrEmpty
}
}
Describe "Select-Object DRT basic functionality" -Tags "CI" {