-
-
Notifications
You must be signed in to change notification settings - Fork 111
fix: flush console output after test completion to prevent truncation (#4545) #4553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…#4545) ## Problem Console output was being truncated when tests completed, particularly when tests ended with Console.Write() without a newline. Users reported that "the end of the output is cut" even after the previous fix in c01a6fc. ## Root Cause While commit c01a6fc fixed parallel output mixing by using per-context buffers, it didn't address output truncation at test completion. When a test ends, any buffered console output (from Console.Write without newline) remains in the test context's line buffer but is never flushed to the sinks. This buffered output is lost and doesn't appear in test results or IDE output. ## Solution Added explicit flushing of console interceptors (stdout and stderr) in the TestCoordinator.ExecuteTestInternalAsync() finally block. This ensures all buffered output is captured before test results are reported. The flush happens: - After test execution completes - In the finally block (always executes, even on exception) - Before result reporting (so output is available in results) - While TestContext.Current still points to the test context - With error handling to prevent flush failures from breaking tests ## Testing - Added OutputTruncationTests with tests ending in Console.Write() - Enhanced ParallelConsoleOutputTests with truncation test case - Existing parallel output isolation tests continue to pass Fixes #4545 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
SummaryAdds console output flushing in the test cleanup path to prevent loss of buffered output from Critical IssuesNone found ✅ SuggestionsNone - the implementation is solid:
The fix addresses the root cause described in the PR: buffered output (from Verdict✅ APPROVE - No critical issues |
Problem
Console output was being truncated when tests completed, particularly when tests ended with
Console.Write()without a newline. Users reported that "the end of the output is cut" even after version 1.12.41 (which included the previous fix in c01a6fc).Example scenario:
Root Cause
While commit c01a6fc fixed parallel output mixing by using per-context buffers, it didn't address output truncation at test completion.
When a test ends, any buffered console output (from
Console.Write()without newline) remains in the test context's line buffer but is never flushed to the sinks. This buffered output is lost and doesn't appear in test results or IDE output.Solution
Added explicit flushing of console interceptors (stdout and stderr) in
TestCoordinator.ExecuteTestInternalAsync()finally block:This ensures all buffered output is captured before test results are reported.
Why this location?
TestContext.Currentstill points to the testTesting
OutputTruncationTests.cs- Tests specifically for output ending without newlineParallelConsoleOutputTests.cs- Added Test4 for truncation scenarioImpact
Console.Write()now capture all output[NotInParallel]testsFixes #4545
🤖 Generated with Claude Code