Skip to content

Render Describing/Context headers in parallel Detailed output#2853

Merged
nohwnd merged 2 commits into
mainfrom
nohwnd-parallel-block-headers
Jul 9, 2026
Merged

Render Describing/Context headers in parallel Detailed output#2853
nohwnd merged 2 commits into
mainfrom
nohwnd-parallel-block-headers

Conversation

@nohwnd

@nohwnd nohwnd commented Jul 9, 2026

Copy link
Copy Markdown
Member

Fix #2824

Problem

In a parallel run (Run.Parallel = $true) with Output.Verbosity set to Detailed or Diagnostic, the Describing ... / Context ... block headers were missing from the console output. They render correctly in a sequential run.

Root cause

Each file in a parallel run is executed by a silent worker (Output.Verbosity = None) whose plugin events are recorded onto a "tape" of live Block/Test objects. The parent replays that tape to its reporting plugins to produce console output.

At the end of every run Pester calls Remove-RSpecNonPublicProperties, which nulls each block's FrameworkData. FrameworkData.CommandUsed is what tells the output plugin whether a block is a Describe or a Context. Because the tape holds live references to the very same block objects, the worker's own end-of-run cleanup blanked out FrameworkData before the parent replayed the tape. Write-BlockToScreen then indexed a report hashtable with a $null key, threw, and the error was swallowed by the non-throwing replay path — so the header silently disappeared.

Sequential runs are unaffected because they write output during the run, before that cleanup runs.

Fix

Set Debug.ReturnRawResultObject = $true on the worker configuration so the worker skips the cleanup and leaves FrameworkData intact on the live tape objects. The parent performs the same cleanup itself on the merged result tree after replaying the tape, so the object returned to the user is still cleaned exactly as before.

Tests

Added a test in tst/Pester.RSpec.Parallel.ts.ps1 asserting that Describing/Context headers appear in Detailed output for a parallel run. Full parallel and output suites pass.

In a parallel run each file is executed by a silent worker whose result
tree is replayed to the parent's reporting plugins. The worker's
end-of-run cleanup (Remove-RSpecNonPublicProperties) strips each block's
FrameworkData, which carries the Describe/Context command name. Because
the replayed tape holds live references to those same block objects, the
parent was left without a CommandUsed and could not render the
"Describing"/"Context" headers in Detailed/Diagnostic output.

Keep the raw result object in the worker so FrameworkData survives until
the parent has replayed the tape; the parent runs the same cleanup on the
merged tree, so the user still receives a cleaned result.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd added this to the 6.1.0 milestone Jul 9, 2026
@nohwnd nohwnd closed this Jul 9, 2026
@nohwnd nohwnd reopened this Jul 9, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd merged commit 8ce645c into main Jul 9, 2026
1 of 3 checks passed
@nohwnd nohwnd deleted the nohwnd-parallel-block-headers branch July 9, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v6 Parallel] Missing block output in Detailed verbosity

2 participants