dotnet test: truncate large failing-host output in summary (#52297)#55300
Open
Evangelink wants to merge 2 commits into
Open
dotnet test: truncate large failing-host output in summary (#52297)#55300Evangelink wants to merge 2 commits into
Evangelink wants to merge 2 commits into
Conversation
When a Microsoft.Testing.Platform test host exits with a failure it often prints its entire command-line help (hundreds of lines) to standard output - for example when an argument has an invalid value. dotnet test echoed all of it verbatim in the executable summary, burying the actual error (which appears at the top) under a wall of noise. Truncate the standard output shown in the summary to the first 30 and last 10 lines with a '... output truncated, N lines omitted ...' marker in between, so the error stays easy to find while trailing diagnostics are preserved. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 75872aa1-648f-46d8-b49f-1b93ce271d0a
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the dotnet test terminal summary for Microsoft.Testing.Platform (MTP) runs by truncating excessively large standard output payloads (e.g., full test-host help dumps on invalid arguments) so the actionable error at the top remains visible.
Changes:
- Add
TerminalTestReporter.TruncateOutputForSummaryand apply it when rendering failing-host stdout inAppendExecutableSummary. - Introduce a localized truncation marker string (
TestApplicationOutputTruncated) and propagate it through regenerated.xlffiles. - Add unit tests covering small-output passthrough, large-output head/tail truncation, and an end-to-end summary assertion via
AssemblyRunCompleted.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Test/TerminalTestReporterTests.cs | Adds coverage for truncation behavior and summary rendering. |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporter.cs | Implements and wires stdout truncation into the failure summary output. |
| src/Cli/dotnet/Commands/CliCommandStrings.resx | Adds the new localized truncation marker resource string. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
| src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf | Regenerated localization entry for TestApplicationOutputTruncated. |
Copilot's findings
- Files reviewed: 16/16 changed files
- Comments generated: 0
Evangelink
enabled auto-merge
July 15, 2026 14:32
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.
Fixes #52297
Problem
When a Microsoft.Testing.Platform test host exits with a failure, it often prints its entire command-line help (hundreds of lines — over 700 for xUnit) to standard output. The classic trigger is an invalid argument value, e.g.
dotnet test --show-live-output true:dotnet testechoed all of it verbatim in the executable summary (AppendExecutableSummary), so the actual error — which appears at the top — was buried under a wall of noise that takes a lot of scrolling to find.Fix
Truncate the standard output rendered in the summary: when it exceeds 40 lines, keep the first 30 lines (where the real error lives) and the last 10 lines (trailing diagnostics), and collapse the middle with a localized marker:
Standard error is left untouched. Output that already fits within the budget is echoed unchanged.
Head+tail elision is used (rather than the existing live-stream tail) because it's robust across failure modes: it preserves the error at the top for the invalid-argument case and trailing output at the bottom for crashes/exceptions.
Changes
TerminalTestReporter.cs— newTruncateOutputForSummaryhelper, wired intoAppendExecutableSummary.CliCommandStrings.resx— new localizedTestApplicationOutputTruncatedstring; all 13.xlffiles regenerated via/t:UpdateXlf.TerminalTestReporterTests.cs— 3 tests: small output unchanged, large output head/tail/marker behavior, and end-to-end throughAssemblyRunCompleted.Verification
dotnet buildofdotnet.csprojanddotnet.Tests.csproj: 0 warnings, 0 errors.