Skip to content

Fix RedirectedOutputDoesNotUseAnsiSequences test failure#126243

Merged
stephentoub merged 2 commits intomainfrom
copilot/fix-redirected-output-test-failure
Mar 28, 2026
Merged

Fix RedirectedOutputDoesNotUseAnsiSequences test failure#126243
stephentoub merged 2 commits intomainfrom
copilot/fix-redirected-output-test-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Description

Fixes the RedirectedOutputDoesNotUseAnsiSequences test failure caused by xunit's background diagnostic reporter thread writing test names to Console.Out while the test has it redirected to a MemoryStream, polluting the captured output.

The fix wraps the test body in RemoteExecutor.Invoke() to run it in an isolated child process where no xunit reporter thread can interfere with Console.Out. This follows the same pattern already used by the sibling test RedirectedOutput_ColorEnvVars_RespectColorPreference in the same file.

Changes

  • Changed [Fact] to [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] to gate the test on RemoteExecutor availability
  • Wrapped the test body in RemoteExecutor.Invoke(static () => { ... }).Dispose() for process isolation

Testing

  • All 4294 System.Console tests pass with 0 failures
  • The specific RedirectedOutputDoesNotUseAnsiSequences test passes reliably

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c6b2ec4b-f010-4dc2-98e3-9c2368ef485f

Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
@stephentoub
Copy link
Copy Markdown
Member

@copilot keep going

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 28, 2026

@copilot keep going

Build and tests completed successfully. All 4294 System.Console tests pass, including the fixed RedirectedOutputDoesNotUseAnsiSequences test (commit 866f32c). The change wraps the test body in RemoteExecutor.Invoke() to isolate it from xunit's background diagnostic reporter thread that was writing test names to Console.Out while the test had it redirected to a MemoryStream.

Copilot AI changed the title [WIP] Fix RedirectedOutputDoesNotUseAnsiSequences test failure Fix RedirectedOutputDoesNotUseAnsiSequences test failure Mar 28, 2026
Copilot AI requested a review from stephentoub March 28, 2026 13:10
@stephentoub stephentoub marked this pull request as ready for review March 28, 2026 13:19
Copilot AI review requested due to automatic review settings March 28, 2026 13:19
@stephentoub stephentoub enabled auto-merge (squash) March 28, 2026 13:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a flaky System.Console color test (RedirectedOutputDoesNotUseAnsiSequences) by isolating it from xUnit’s background diagnostic output, which can write to Console.Out and corrupt the test’s redirected output capture.

Changes:

  • Convert the test from [Fact] to a RemoteExecutor-gated [ConditionalFact].
  • Execute the test body inside RemoteExecutor.Invoke(...) to run it in an isolated child process.

@stephentoub stephentoub merged commit fde1d67 into main Mar 28, 2026
99 of 102 checks passed
@stephentoub stephentoub deleted the copilot/fix-redirected-output-test-failure branch March 28, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

RedirectedOutputDoesNotUseAnsiSequences test failing

4 participants