A test that runs Invoke-Pester itself and captures the host output gets nothing back when the outer run has Run.Parallel enabled. The nested run's output ends up on the console instead, detached from the test that produced it.
Write-PesterHostMessage diverts to the tape when $parallelOutputTape is set (Output.ps1:139), and the worker sets it for the whole run, so anything the nested run writes goes there too. 6>&1 around the nested call then captures nothing, and the parent replays the nested output later as if it were the worker's own.
Repro, the tags rendering tests in tst/functions/Output.Tests.ps1 do exactly this:
$c = New-PesterConfiguration
$c.Run.Path = './tst/functions/Output.Tests.ps1'
$c.Run.Parallel = $true
Invoke-Pester -Configuration $c
# 4 failed, the same 4 pass with Run.Parallel = $false
The tape is per run, but it is read from module scope, so a run that starts inside another run picks up its parent's. It should be scoped so a nested run writes where its own caller can see it.
Found while turning Run.Parallel on for our own test suite, where it is the reason Output.Tests.ps1 needs #pester:no-parallel.
🤖
A test that runs
Invoke-Pesteritself and captures the host output gets nothing back when the outer run hasRun.Parallelenabled. The nested run's output ends up on the console instead, detached from the test that produced it.Write-PesterHostMessagediverts to the tape when$parallelOutputTapeis set (Output.ps1:139), and the worker sets it for the whole run, so anything the nested run writes goes there too.6>&1around the nested call then captures nothing, and the parent replays the nested output later as if it were the worker's own.Repro, the tags rendering tests in
tst/functions/Output.Tests.ps1do exactly this:The tape is per run, but it is read from module scope, so a run that starts inside another run picks up its parent's. It should be scoped so a nested run writes where its own caller can see it.
Found while turning
Run.Parallelon for our own test suite, where it is the reasonOutput.Tests.ps1needs#pester:no-parallel.🤖