Test stray output during a real run, not only Split-RSpecResult#2822
Merged
Conversation
The two tests added in #2746 only exercised internals (Split-RSpecResult and the typed result list), so neither covered a real run that emits stray output. Replace the redundant one with an end-to-end Invoke-Pester run that leaks to the success stream from Run.BeforeContainer - the same path a stray native-command write takes - and assert the run completes with its results intact and a warning instead of crashing. Keep a focused Split-RSpecResult unit test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 #2818
Background
PR #2746 (Fix #2655, "Don't crash the run on stray output during a test run") added two tests, but as noted in review both only exercised internals —
Split-RSpecResultand the typed result list — so neither actually ran Pester end-to-end with stray output.Change
Invoke-Pesterrun that deterministically leaks stray output to the success stream fromRun.BeforeContainer(dot-sourced insideInvoke-Test's container loop, the sameInvoke-Test→Split-RSpecResultpath a stray native-command write hits). It asserts the run completes, the container and its results are kept, and a warning is emitted instead of the run crashing.Split-RSpecResultunit test for the separation logic.Validation
tst/Pester.RSpec.ts.ps1— 116 P-tests pass (verified in isolation onmain).