Browse Source

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 <ai@example.com>
pull/118/head
Raimund Andree 2 days ago
parent
commit
d61dffab46
  1. 7
      Tests/PipelineControl.Tests.ps1

7
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 }
}

Loading…
Cancel
Save