Repository navigation
Keep a nested run out of the parallel worker's output tape - #3085
Merged
Merged
Conversation
A worker silences its run and appends everything it writes to a module-scope tape, so the parent can replay it in order. The tape is module scope, so a run that starts inside the worker's run saw it as well: a test that calls Invoke-Pester itself and captures the output with 6>&1 got nothing back, while that output went to the tape and the parent replayed it later as if the worker had written it. A nested run belongs to its own caller, so it now puts the tape aside for its duration and gives it back when it ends. Invoke-Pester already knows whether it is nested, and already has the finally that restores the outer run's global mocks, so the tape rides along with that. A worker's own run is not nested, so it keeps the tape. 🤖
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #2991
A worker silences its run and appends everything it writes to a module-scope tape, so the parent can replay it in order. The tape is module scope, so a run that starts inside the worker's run saw it as well. A test that calls
Invoke-Pesteritself and captures the output with6>&1got nothing back, while that output went to the tape and the parent replayed it later as if the worker had written it.A nested run belongs to its own caller, so it now puts the tape aside for its duration and gives it back when it ends.
Invoke-Pesteralready knows whether it is nested,$runningPesterInPester, and already has thefinallythat restores the outer run's global mocks, so the tape rides along with that. A worker's own run is not nested, so it keeps the tape.The repro is in our own suite.
tst/functions/Output.Tests.ps1withRun.Parallelon:The four failures were the tags rendering tests, which capture the output of a run they start themselves.
The test in
tst/Pester.RSpec.Parallel.ts.ps1fails without the fix, on the second assertion: the parent's own captured output contains the nested run'sDescribing InnerNestedline, which is the replay../test.ps1 -NoBuildon this branch: 3037 passed, 0 failed, 3 skipped.🤖