Skip to content

[rel/4.5] Preserve MTP report causes and await canceled MSTest workers - #12297

Merged
Amaury Levé (Evangelink) merged 1 commit into
rel/4.5from
dev/amauryleve/release-4-5-backports-578
Nov 9, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
rel/4.5from
dev/amauryleve/release-4-5-backports-578

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Pull request

Summary

Backport the remaining applicable reporter and worker-start cancellation fixes to rel/4.5, with the paired logging-test reliability corrections.

Upstream Included servicing change
#12282, 17ea6d5771408b3da32413f6a76f59ef982c869d Preserve nested and aggregate exception causes in CTRF, HTML and JUnit reports; retain explanations, simple-exception traces, capture bounds, unit coverage and the real packaged-consumer regression.
#12288, cb5805342d403ed9f7e7ddd116c81fee789ef7f9 Check cancellation before starting workers, then await every scheduled worker in both ordinary and dependency-ordered MSTest execution.
#12237 and #12251, bacb2826dbf20a0192a6753a61a98743faf5d4f8 and 87a1f43d3cc04608b5b8b0f662b1fd3a9583518d Test-only logging-relocation rendezvous, exact replacement-stream assertions and bounded worker cleanup, including the portable synchronous wait probe.

This is one commit and 10 files. The base already includes the independently merged Retry/TRX backport #12290; this PR does not duplicate it.

Design and decision record

These are servicing fixes using the upstream rationale and regression tests in the linked PRs, not a new feature or architecture. A separate design document is not needed.

Keep all release target frameworks, public/shipped API baselines and CLI options unchanged. In particular, keep CTRF and JUnit on their existing experimental 1.0.0-dev version family rather than importing main's JUnit graduation. Package readmes describe the corrected diagnostics without changing that policy.

Exclude main-only agent guidance, the absent CompatibilityPolyfillTests fixture, the absent HangDump lifecycle fixtures from #12285, new features, retargeting and unrelated refactors/dependency updates.

Consumer contract: an ordinary net10.0 executable consumes freshly packed MTP 2.5.3-dev, HTML 2.5.3-dev, CTRF 1.0.0-dev and JUnit 1.0.0-dev. Its application owns and flushes the reporters before exit. Five distinguishable results must retain their associated UID/name/outcome, explanation and causes in each final artifact. Four intentionally failing/error results make the child exit 2; the outer acceptance case must pass with exit 0. No handshake, capability, fallback, schema or multi-module protocol is changed.

Demonstration

The actual packed consumer produced five results in each of CTRF, HTML and JUnit: NestedFailure, AggregateFailure, ExplainedFailure, SimpleFailure and PassingTest. The acceptance case asserts their individual identities and outcomes rather than searching the whole report for expected strings.

Before the fix, expanding NestedFailure showed its type/message but no inner trace. After the fix, the rendered HTML includes:

System.InvalidOperationException: Invocation failed.
 ---> System.ArgumentException: [INNER_CAUSE] Service rejected <401> & "credential".
   --- End of inner exception stack trace ---

Inspected the generated HTML in the browser at 1280x721 CSS pixels and in a constrained 479x699 embedded viewport. Expanded nested and aggregate results, checked the errored filter, literal markup/quotes, both aggregate branches and wrapped diagnostic blocks. The inspected diagnostic blocks fit their available width without horizontal clipping. The surrounding page still showed horizontal overflow at the constrained size; no HTML/CSS/layout change is included here.

Rendered captures were inspected locally. This text excerpt avoids publishing the report header's environment/machine metadata.

Validation and regression proof

Validated head: 279c8710539dfb83ab7f6f683f29ffc7b0ac2f3f, tree f2f4df706c8e7b0e8391e1d72d834b2c71a2caf8, parent a230ee4bb0d84452157ae568528a12069af76732.

The exact-head counterfactual reverses only the three production-file fixes, retaining byte-identical regression tests, logging repairs and all incoming release changes. Counterfactual patch SHA-256: F519CCD2D0E85BAC7DD4ED905439700885568FB7F623C5A5D2AD818390EBDFFB.

Both counterfactual and restored-final full Release builds/packs passed with exit 0, zero warnings/errors, all release targets including classic UWP, and package content/metadata validation intact. The repository-pinned SDK was 12.0.100-alpha.1.26480.103. Final working-tree source was restored exactly to the committed revision.

Test-value evidence

Contract / named tests Without the fix Correct implementation Evidence / limitation
RunTests_CancelledWhileStartingParallelWorkers_WaitsForScheduledWorkers and RunTests_CancelledWhileStartingDependencyWorkers_WaitsForScheduledWorkers Executed: both fail on every adapter test TFM, 10 intended failures, exit 2. Assertions report run.IsCompleted unexpectedly true, one worker scheduled instead of two, and the premature cancellation exception. Executed: 10/10 pass, exit 0. Same tests and selection on net8.0, net9.0, net462, net48 and net8.0-windows10.0.18362.0.
TestResultCaptureHelperTests, including TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace, TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics, TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTrace and TryCapture_NestedException_KeepsDiagnosticTraceBounded Executed: seven intended null-trace assertions fail per TFM; 28 failures and 88 passing controls overall, exit 2. Executed: 116/116 pass, exit 0. Same 29 cases on net8.0, net9.0, net462 and net472. Covers failed/error/timeout/cancelled states, explanations, aggregate branches, truncation and the simple-thrown-exception compatibility control.
Reports_NestedExceptions_PreserveAssociatedCausesAndExplanations Executed: the real packed-consumer case fails at CTRF result 'nested' must retain its nested exception trace, outer exit 2. Executed: 1/1 passes, outer exit 0; intentionally failing child exits 2. Parses all five associated results in all three final formats. Independent discovery and the canonical execution verifier reconcile 1 planned/selected/executed/passed, zero skips.
Complete TestExecutionManagerTests and CleanupCancellationIsolationTests controls Not claimed as additional counterfactual proof. Executed: 162 execution-manager controls and 13 packed cleanup/cancellation cases pass, exit 0, no skips. Existing WIN_UI compilation excludes three deployment cases: 33 cases on each other TFM, 30 on WinUI. Packed controls exercise normal/failure/cancellation/timeout paths, reflection/source generation and Framework failure identities, and assert loaded adapter bytes against the current package.
DiagnosticLoggingInformationTests, especially both rows of SynchronousLoggerCreatedBeforeRelocationWaitsForReplacement Preservation baseline: 21/21 pass before the test-only repairs. Executed: 24/24 pass after the repairs. net8.0/net9.0/net462; shipping logger source is unchanged. This is green-before/green-after evidence, not a claimed reproduction of the intermittent flake.

Final matrix: 326 passing focused executions, zero failures/skips. This total includes the separately selected worker regressions also exercised by the complete manager class.

Commands and outcomes

Commands ran from the backport worktree. Only task-owned binlog/results directories are parameterized below. Each discovery command used the same selector as its execution.

# Used for final-red-pack.binlog and green-pack.binlog.
# Both passed: exit 0, zero warnings/errors; package audit passed.
& $env:ComSpec /d /c 'set "PATH=%CD%\.dotnet;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32;%PATH%" && set "PATHEXT=.COM;.EXE;.BAT;.CMD" && call build.cmd -pack -c Release -msbuildEngine vs /p:EnableCodeCoverage=false /m:4 /nr:false /bl:<task-owned-binlog>'

$dotnet = '.\.dotnet\dotnet.exe'
$report = @('--report-trx', '--report-trx-filename', 'tests.trx',
    '--results-directory', $results, '--no-ansi', '--progress', 'off',
    '--show-test-results', 'failed')

# Worker selection: 2 intended red failures / 2 green passes for each of the five TFMs.
# The Framework runs execute the corresponding project EXE directly.
& $dotnet "artifacts\bin\MSTestAdapter.PlatformServices.UnitTests\Release\$tfm\MSTestAdapter.PlatformServices.UnitTests.dll" `
    --treenode-filter '/*/*/TestExecutionManagerTests/RunTests_CancelledWhileStarting*' @report

# Complete manager class: 33 green passes per ordinary/Framework TFM; 30 on WinUI.
& $dotnet "artifacts\bin\MSTestAdapter.PlatformServices.UnitTests\Release\$tfm\MSTestAdapter.PlatformServices.UnitTests.dll" `
    --treenode-filter '/*/*/TestExecutionManagerTests/*' @report

# Capture: 29 executed per TFM, red 7 failed/22 passed; green all 29 passed.
# net462/net472 use Microsoft.Testing.Extensions.UnitTests.exe directly.
& $dotnet "artifacts\bin\Microsoft.Testing.Extensions.UnitTests\Release\$tfm\Microsoft.Testing.Extensions.UnitTests.dll" `
    --filter 'FullyQualifiedName~TestResultCaptureHelperTests' @report

# Logging: baseline 7 and final 8 passed per TFM; net462 uses the project EXE.
& $dotnet "artifacts\bin\Microsoft.Testing.Platform.UnitTests\Release\$tfm\Microsoft.Testing.Platform.UnitTests.dll" `
    --filter 'FullyQualifiedName~DiagnosticLoggingInformationTests' @report

# Real packed report consumer: red 1 intended failure/exit 2; green 1 pass/exit 0.
& $dotnet artifacts\bin\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Release\net11.0\Microsoft.Testing.Platform.Acceptance.IntegrationTests.dll `
    --filter 'FullyQualifiedName~ReportExceptionDiagnosticsTests' @report

# Existing packed MSTest controls: 13 passed, exit 0.
& $dotnet artifacts\bin\MSTest.Acceptance.IntegrationTests\Release\net11.0\MSTest.Acceptance.IntegrationTests.dll `
    --filter 'FullyQualifiedName~CleanupCancellationIsolationTests' @report

Discovery used --list-tests plus the corresponding filter and --no-ansi, without execution reporters. All discovery commands exited 0. The canonical verify_execution.py from main, blob 3b5e3831555cc756dd9d3ff812cfd3c6f7e9abe2, verified both package-consuming selections against source-derived exact case names (1 report case and 13 cleanup cases).

The local build launcher/PATH setup and execution-plan formatting/count issues were resolved before accepting the final proof. They were not counted as behavioral failures.

Package provenance

Each compared state was repacked before its consumer ran. Separate fresh consumer caches were verified in project.assets.json; all four executed Core/CTRF/HTML/JUnit DLLs matched the selected lib/net9.0 entries in that state's shipping packages byte-for-byte. The three reporter binaries differ between the red and green variants; Core remains identical. The green packages identify the exact validated head above.

Final package Version SHA-256
Microsoft.Testing.Platform 2.5.3-dev 0E2FAECBBF99C707187EE546ED8E882C8FC0C53C1C49AD23C5BB1F4975A14374
Microsoft.Testing.Extensions.CtrfReport 1.0.0-dev AE8E34255FDAC48D4052471BC45E5F8F96889C799E09212620A5247F3DA5BD6D
Microsoft.Testing.Extensions.HtmlReport 2.5.3-dev D29FCA7F42E84C3942D5C00BBA03FFBDC57E6BB04D36A5E355B9D40DABCE0493
Microsoft.Testing.Extensions.JUnitReport 1.0.0-dev 10E70C5CCAAAFD90C410E68FCD9AF641ED37AB86FE190807A8FEC51E05F8DE8E

Binlogs, TRX reports, source-state patches and package/binary manifests are retained in task-owned local artifacts, not represented as public artifact links. Validation was on Windows; Linux/macOS, hosted CI for this PR head and hosted/IDE report consumers have not been verified. No auto-merge is requested.

Backport the applicable portions of #12282 (17ea6d5) and #12288 (cb58053), retaining release APIs, target frameworks and experimental reporter versions.

Include the paired test-only logging reliability corrections from #12237 (bacb282) and #12251 (87a1f43).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Nov 9, 2026

@github-actions github-actions Bot 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.

🧪 Test quality review — PR #12297

🧵 Parallel safety

STATUS: PARTIAL — the parallel-safety specialist was not run in this pass, so coverage is incomplete. This is not a clean result. Run /parallel-audit for a full assessment.

Per-test grades

Static review only. I did not run the mutation analysis, so Mutation is N/A throughout. No inline suggestions were posted because I could not anchor an exact edit to a changed line.

GradeTestMutationNotesHow to improve
B (80–89) new ReportExceptionDiagnosticsTests.
Reports_
NestedExceptions_
PreserveAssociatedCausesAndExplanations
N/A One long scenario with a local helper; a failure doesn't isolate the report format. Split into per-format tests, or compare the exact JUnit failure text with a raw-string literal.
B (80–89) new TestExecutionManagerTests.
RunTests_
CancelledWhileStartingParallelWorkers_
WaitsForScheduledWorkers
and ...DependencyWorkers_
WaitsForScheduledWorkers
N/A The 60s timeout fallback is deterministic. Asserts that nothing ran, but not the 2nd worker's skip reason. Also assert the exact outcome of the second test when cancellation was requested.
A (90–100) new TestResultCaptureHelperTests.
TryCaptureCore_
NestedException_
PreservesInnerDiagnosticTrace
(4 data rows)
N/A Covers each state type with the cause text asserted. —
A (90–100) new TestResultCaptureHelperTests.
TryCaptureCore_
AggregateException_
PreservesAllInnerDiagnostics
, ...ExplanationWithNestedException_
PreservesExplanationAndTrace
, ...SimpleThrownException_
PreservesOriginalStackTrace
, TryCapture_
NestedException_
KeepsDiagnosticTraceBounded
N/A Focused scenarios with exact or boundary assertions. —
A (90–100) mod DiagnosticLoggingInformationTests.
SynchronousLoggerCreatedBeforeRelocationWaitsForReplacement
N/A Rendezvous-based with bounded waits and both sync and async paths. —

This advisory review is heuristic and non-blocking.

Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 31.3 AIC · ⌖ 0.722 AIC · ⊞ 7.6K · ◷

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 9, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 9, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 9, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Nov 9, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit d54bb2c into rel/4.5 Nov 9, 2026
28 of 33 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/release-4-5-backports-578 branch November 9, 2026 19:52
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Nov 9, 2026
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.

2 participants