From d61dffab46376ad4bcec70da7e53cbf70e71cfac Mon Sep 17 00:00:00 2001 From: Raimund Andree Date: Fri, 9 Oct 2026 18:04:47 +0000 Subject: [PATCH] test: name the error action where a test needs a non-terminating error The CI runner sets $ErrorActionPreference to Stop, so three new PipelineControl tests that take the error of a nested folder through 2>&1 ended at the first error before the later command saw it (elevated Windows PowerShell 5.1 of the frozen run: three failures). They now pass -ErrorAction Continue. The focused runner of this work did not set the preference and missed it; it does now. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant --- Tests/PipelineControl.Tests.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/PipelineControl.Tests.ps1 b/Tests/PipelineControl.Tests.ps1 index 79a6f4e..32867ba 100644 --- a/Tests/PipelineControl.Tests.ps1 +++ b/Tests/PipelineControl.Tests.ps1 @@ -496,12 +496,13 @@ Describe 'A later command and the error of a folder that Get-ChildItem2 cannot r # Before 5.0.0-rc7, the recursion took what the later command threw for the error of a nested folder as a failure of # the folder above it, wrote a verbose message, and left the loop over the folders: the listing ended early and the - # caller never saw the exception. + # caller never saw the exception. The error action is named because the CI runner sets $ErrorActionPreference to Stop, + # which would end the listing at the first error before the later command saw it. It 'Should pass on what a later command throws when it takes the error of a nested folder' { $emitted = 0 $caught = $null try { - Get-ChildItem2 -Path $errorTree -Recurse -File 2>&1 | ForEach-Object -Process { + Get-ChildItem2 -Path $errorTree -Recurse -File -ErrorAction Continue 2>&1 | ForEach-Object -Process { $emitted++ throw 'Downstream failure' } @@ -521,7 +522,7 @@ Describe 'A later command and the error of a folder that Get-ChildItem2 cannot r $emitted = 0 $reachedEnd = $false foreach ($round in 1) { - Get-ChildItem2 -Path $errorTree -Recurse -File 2>&1 | ForEach-Object -Process { + Get-ChildItem2 -Path $errorTree -Recurse -File -ErrorAction Continue 2>&1 | ForEach-Object -Process { $emitted++ if ($Keyword -eq 'break') { break } else { continue } }