From e15133d64c6dfb59d2346a40200996ff2e8c9b73 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 18 Oct 2019 16:49:24 -0700 Subject: [PATCH 1/2] BUG: Fix command runtime so StopUpstreamCommandsException doesn't get leaked to user --- .../engine/MshCommandRuntime.cs | 3 ++- .../Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index f9e4b6bae6e..cf1260f1fc9 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2381,7 +2381,8 @@ public Exception ManageException(Exception e) // 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 { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 index 872b7850497..63449c8f9be 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 @@ -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 internal exception for stopping upstream" { + 1,2 | Select-Object -First 1 -ErrorVariable err + $err | Should -BeNullOrEmpty + } } Describe "Select-Object DRT basic functionality" -Tags "CI" { From 8de01b8ff99116db9483bd46dcf6f50bc8fa023d Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 20 Oct 2019 09:27:11 -0700 Subject: [PATCH 2/2] Update test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 Co-Authored-By: Ilya --- .../Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 index 63449c8f9be..d04ce8d0695 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 @@ -115,7 +115,7 @@ Describe "Select-Object" -Tags "CI" { $dirObject[$TestLength].Size | Should -Be ($orig2 + 1) } - It "Should not leak internal exception for stopping upstream" { + It "Should not leak 'StopUpstreamCommandsException' internal exception for stopping upstream" { 1,2 | Select-Object -First 1 -ErrorVariable err $err | Should -BeNullOrEmpty }