Use truncating logger by default for all tests - #54795
Merged
dsplaisted merged 1 commit intoJun 17, 2026
Merged
Conversation
dsplaisted
requested review from
a team and
MichaelSimons
and removed request for
a team
June 16, 2026 13:49
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes bounded (head+tail) output logging the default for TestCommand.Execute to avoid test timeouts/hang-dump cancellations caused by extremely verbose command output (e.g., dotnet test -v diag) flooding the test host IPC channel, and adds/updates tests and documentation around the truncation behavior.
Changes:
- Default
TestCommand.Executeto echo command output throughTruncatingTestOutputHelper, with an opt-out (DisableTruncatedOutputLogging/WithoutTruncatedOutputLogging()). - Improve
TruncatingTestOutputHelpertail eviction so a tiny final line can’t evict a much larger recent line, and adjust omission-note emission. - Add focused unit tests for truncation edge cases and remove the previous one-off limiter from the verbosity integration test.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.NET.TestFramework/TruncatingTestOutputHelper.cs | Refines tail-eviction logic (LinkedList + boundary trimming) and expands remarks to document the behavior. |
| test/Microsoft.NET.TestFramework/Commands/TestCommand.cs | Enables truncating logger by default in Execute, adding an opt-out flag/method. |
| test/dotnet-test.Tests/TruncatingTestOutputHelperTests.cs | Adds unit tests covering head/tail retention, omission notes, and the “tiny final line” edge case. |
| test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs | Removes the special-case diag limiter now that truncation is default. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| // Dropping this whole line would remove more than necessary, discarding recent | ||
| // output. Trim just its leading (oldest) characters instead. | ||
| _tail.First.Value = oldest.Substring(overBy); |
joeloff
approved these changes
Jun 16, 2026
Member
Author
|
/azp run sdk-source-build |
|
Azure Pipelines successfully started running 1 pipeline(s). |
dsplaisted
added a commit
that referenced
this pull request
Jul 16, 2026
…Execute The 9.0.1xx to 9.0.3xx merge conflict in TestCommand.cs was resolved by keeping BOTH the truncating end-of-run logging (from 9.0.1xx, #54795) and the unbounded real-time per-line echo (Log.WriteLine for every output/error line, from 9.0.3xx). That double-logs command output and defeats the truncation: the real-time echo writes the full output to Log with no cap, re-flooding the test host IPC channel and reintroducing the spurious hang-dump timeouts #54795 was meant to prevent. Resolve to the truncation approach for 9.0.3xx: drop the real-time OnOutputLine/OnErrorLine echo (and the associated 'Executing/exited' display logging) and keep the bounded LogCommandResult via TruncatingTestOutputHelper. Note: main and 10.0.x intentionally keep the real-time echo (a different fix applies there), so the truncation should not flow past 9.0.3xx. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 59570d89-a7e3-4993-baa9-3fb1f442a617
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.
Follow-up to #54642. Fixes some issues @MichaelSimons found, and enables the truncating logger for all tests, rather than just the one that I had noticed was timing out due to large logs.