Skip to content

Use truncating logger by default for all tests - #54795

Merged
dsplaisted merged 1 commit into
dotnet:release/9.0.1xxfrom
dsplaisted:truncate-test-output-by-default
Jun 17, 2026
Merged

Use truncating logger by default for all tests#54795
dsplaisted merged 1 commit into
dotnet:release/9.0.1xxfrom
dsplaisted:truncate-test-output-by-default

Conversation

@dsplaisted

Copy link
Copy Markdown
Member

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.

Copilot AI review requested due to automatic review settings June 16, 2026 13:48
@dsplaisted
dsplaisted requested a review from a team as a code owner June 16, 2026 13:48
@dsplaisted
dsplaisted requested review from a team and MichaelSimons and removed request for a team June 16, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.Execute to echo command output through TruncatingTestOutputHelper, with an opt-out (DisableTruncatedOutputLogging / WithoutTruncatedOutputLogging()).
  • Improve TruncatingTestOutputHelper tail 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);
@dsplaisted

Copy link
Copy Markdown
Member Author

/azp run sdk-source-build

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@dsplaisted
dsplaisted merged commit d32f471 into dotnet:release/9.0.1xx Jun 17, 2026
37 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants