You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve MSTest global cleanup after local cancellation - #12225
Port the cleanup-cancellation isolation fix from merged #12220 (rel/4.5) to main. Relates to #6157; the broader initialization/lifetime discussion remains open.
A cooperative timeout or explicit cancellation in local TestCleanup must not prevent independent GlobalTestCleanup from entering solely because the same context cancellation source was poisoned. Renew that source only at the global-teardown boundary while retaining the original failure, active whole-test/run cancellation budgets, and inherited-local/multiple-global fail-fast rules.
No public/internal API, default-timeout, or healthy-path token-identity changes. The initial port matched the approved lifecycle/test source. Review follow-ups additionally preserve noncooperative cleanup completion within the whole-test budget, report secondary global cleanup failures, and honor the source-generation opt-out.
Design and decision record
This is a bounded bug fix, not a new feature. The investigation and decision on #6157 and merged #12220 are the maintained rationale; no separate feature RFC is needed.
Keep the existing initializer cancellation guard. Do not reset the token before every lifecycle call: doing so can lose already-delivered cancellation or restart a test deadline. Capture local failure before global teardown, preserve cancellation even when local cleanup returns normally, and re-register only budgets still active at cleanup entry against the renewed source. Budgets consumed before cleanup retain the existing fresh-teardown policy.
Review follow-up: fixture cancellation during claimed cleanup must not stop the whole-test monitor. The monitor has its own cancellation signal and an owned deadline source that remains alive until both the monitor and invocation finish. Deadline/run cancellation reaches renewed cleanup sources without restarting the budget. Local/global failures are appended through TestResult's ordered aggregation; a local timeout keeps its classification, while an independent global failure cannot leave an inconclusive result. The live context source remains usable after cleanup, consistent with TestContext's existing ownership policy; its cancellation registrations are scoped.
Demonstration
The change is nonvisual lifecycle/resource behavior; a trace is clearer than a screenshot:
Before local cooperative cleanup timeout:
global-initialize -> test-body -> local-cleanup -> dispose
global-cleanup never enters; owned resource remains
After:
global-initialize -> test-body -> local-cleanup -> dispose -> global-cleanup
owned resource removed; original local timeout still reported
The unrelated-local-exception control already ran global cleanup before the fix. The acceptance fixture checks both NoBaseTest and WithBaseTest, exact TRX identity/class/outcome association, full traces and resource removal; a separate case actually executes source-generated metadata.
Validation and regression proof
Previously validated port head: 244fa660c66690bbc9a6704978042671dc6a515b, based on 88a31ec394abe9f5c5dcf596f0a150ff998d3a0e. The following original-port evidence is historical; current review-fix evidence is recorded below. Repository-pinned SDK 12.0.100-alpha.1.26509.101, Windows x64, Debug producers; real net10 package consumers are built in Release. The SDK-current outer acceptance host is net12.
Current-main warning-as-error unit build: passed, exit 0.
Current-main warning-as-error package builds: 21 product/consumer prerequisite packages rebuilt successfully, exit 0; fixed adapter, framework and platform are from this head.
Current-main CleanupCancellationIsolationTests: 8 executed/passed, 0 failed/skipped, exit 0, including actual source-generated metadata. The repository execution gate independently reconciled all eight expected case names/counts.
All 16 fresh child adapter loads matched the actual packed platform-services DLL, including two source-generated loads. Adapter nupkg SHA-256: 37DF33D91E4408A976E9E3C05D462D97871CD444F73B23B5C33FFB93C7FE801F; loaded DLL SHA-256: DABB54357194BDCA013EB68F88A884677DE19C2530590E6AA9B96EB2C2E9331C. The nupkg repository commit is this exact head.
Exact functional selectors/arguments (machine-local result/binlog roots are parameterized as $evidence):
Build/pack properties: -c Debug --no-restore -v minimal -nodeReuse:false -p:TreatWarningsAsErrors=true -p:MSBuildTreatWarningsAsErrors=true -p:SkipUapTargetFramework=true -p:SupportedNetFrameworks=net10.0 -p:ModernUwpMinimum= -p:WinUiMinimum=, with a unique quoted -bl argument per invocation. The unit build additionally selects -f net10.0. Actual current-main packages are rebuilt with those properties before the acceptance run; old same-version caches are not used as proof.
The build/pack command forms below all passed with exit 0; $common is the exact shared property set above and $evidence parameterizes only the machine-local artifact root:
The same per-project pack form also rebuilt the actual eager acceptance prerequisites (analyzers, platform MSBuild integration, TRX/abstractions, telemetry, configuration, hosting, logging, OpenTelemetry, CTRF, JUnit, GitHub Actions, PackagedApp, retry, video and Azure Foundry); this is not a claimed whole-repository/UAP package-inventory pass.
The named packed cases are GlobalCleanup_Normal, GlobalCleanup_UnrelatedLocalFailure, GlobalCleanup_LocalCancellationWithoutException, GlobalCleanup_LocalCancellationException, GlobalCleanup_CancellationWithUnrelatedLocalFailure, GlobalCleanup_LocalCooperativeTimeout, GlobalCleanup_PreservesLocalTimeoutWhenGlobalCleanupThrows, and GlobalCleanup_LocalCooperativeTimeout_SourceGeneration.
Local logs/TRX and payload-hash manifests are retained; no public artifact upload or CI pass is claimed. This is focused MTP reflection/source-generation validation, not a full OS/TFM/UAP matrix or an independent VSTest pass. The original optional VSTest probe had the same zero-test framework-loader mismatch with original and fixed packages; it was not counted as behavioral evidence or expanded into an unrelated packaging change.
Test-value evidence
Contract / test group
Counterfactual executed before this mechanical rebase
Correct implementation
13 GlobalCleanup* unit regressions
Same tests retained without the production fix: 13 executed, 9 intended behavioral failures and 4 controls passed; exit 2.
13/13 passed before rebase; all 13 are also included in the freshly passing current-main 139-test selection.
Eight CleanupCancellationIsolationTests cases
Original packed adapter with the same tests: 8 executed, 6 resource-release assertion failures and 2 controls passed; exit 2.
8/8 passed before rebase and freshly on this head after rebuilding/repacking the current main product family.
The prior main evidence is bound to original commit e0ce525219a1e10bcce8d2b3ab048b03ac26b495 (base 92e83edafb54811009aae479caf29a763f19a99a plus the recorded test patch). All three approved source/test blobs are byte-identical after rebase; current unit/shipping green validation is reported separately rather than presenting the earlier red run as a new run on the rebased head. Merged #12220 independently reproduced the same release-bound red/green behavior.
Review-fix revision and test-value evidence
Current review revision: 99e4e2dd546269b34c1310485bfd196f9f774c72, directly based on 244fa660c66690bbc9a6704978042671dc6a515b. Windows x64, pinned SDK 12.0.100-alpha.1.26509.101, runtime 10.0.14, Debug producers/outer hosts and Release net10 consumers. All 21 product/acceptance prerequisite packages were repacked at this revision with compiler/MSBuild warnings as errors.
Static original defect: the unconditional source-generated row required intentionally absent build output. No fabricated paired execution claim.
Executed: MSTEST_ACCEPTANCE_SKIP_SOURCEGEN=1 and true each discover/execute/pass exactly eight reflection cases, zero failed/skipped. With the opt-out unset, all ten cases pass, including both source-generation rows.
Final unit selection: 146 executed, 146 passed, zero failed/skipped, exit 0. The same retained unit selection against the original implementation executed 146 cases with seven intended failures and 139 controls passed, exit 2. The retained final test patch SHA-256 is C167BCB71EDA99D24AF056036D399B58DDA92A475836A66F558D60CA1F5EB736.
Final packed selection: 10/10 passed with source generation enabled, 8/8 passed for each opt-out value, all outer exits 0 and no skips. Original packed selection: 10 executed, three intended assertion failures and seven controls passed, exit 2. Failing child tests remain intentional (child exit 2); the outer checks assert the correct preserved failures rather than accepting a false success.
The fixture now reads and asserts product-provenance.txt, reports explicit loaded-assembly-count failures instead of an opaque Single() failure, and sets child DOTNET_CLI_UI_LANGUAGE=en-US. All 52 final child adapter loads matched the current nupkg payload. Adapter package MSTest.TestAdapter.5.0.0-dev.nupkg SHA-256: 144329172D902BA9A60A97FB550A34412BBC578FE564786CB49058D198BC6E86; loaded platform-services DLL SHA-256: ACC8555FB59347354A0DF000542EFD01DEC42DD7EBC55CC2684E060E4CA19FDC. Its nupkg repository commit equals this exact review revision. The original packed comparison used package SHA-256 12C5153E9D4D589766F0850FE152C69780A9D47EB5D0406A82D246A83026C6A7 / loaded DLL B9029F9D48C898C15907A6D28428CBD64592597A050B2EBFA50CDB87B29675F4.
Exact final command forms, all passed / exit 0 ($evidence parameterizes only the local evidence directory):
The same per-project pack form rebuilt the other 20 prerequisite packages already enumerated above; no whole-repository/UAP inventory pass is claimed. The repository execution gate independently reconciled each source-declared plan with its fresh outer TRX and exit. Logs, TRX, package hashes and resolved consumer assets are retained locally; the concise assertion excerpts/counts above are the published evidence, not an invented artifact URL.
This is nonvisual lifecycle behavior; executable traces and final TRX/resource assertions are more useful than staged screenshots. Validation is focused Windows net10 reflection/rooting-source-generation coverage, not a full OS/TFM/VSTest/AOT matrix. CI has not been awaited. These review fixes target main only; merged #12220 on rel/4.5 was not modified, so any corresponding servicing/backport needs remain separate.
Addresses #6157. Renew only a canceled global-cleanup source while retaining original failures, active test/run budgets, and existing fail-fast rules. Add deterministic cancellation/deadline regressions and packaged reflection/source-generation resource-release coverage.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Compared merge base 88a31ec394abe9f5c5dcf596f0a150ff998d3a0e with head 244fa660c66690bbc9a6704978042671dc6a515b. Evidence applies to this head, not every intermediate commit. Static review only; no code was built or executed.
Test-value evidence
Contract
Scenario / decisive assertion
Counterfactual
Evidence status
Global cleanup runs after local cleanup cancellation and the original failure is preserved
Without the lifecycle change the global cleanup is skipped, so the trace and resource-release assertions fail
Static prediction. The PR body reports an executed red/green run (9 of 13 unit tests and 6 of 8 acceptance cases failed without the fix), bound to the earlier original commit; it was not independently verified here.
Healthy token not refreshed; active test or run deadline kept; expired deadline not restarted
Unit GlobalCleanupDoesNotRefreshHealthyToken, ...RetainsActiveTestDeadline..., ...DoesNotRestartExpiredTestDeadline, ...IgnoresAlreadyExpiredTestDeadline, ...RunCancellation variants (token identity and IsCancellationRequested)
Always renewing the source would change token identity or lose the deadline, so these assertions would fail
Static prediction
Inherited-cleanup and multiple-global-cleanup fail-fast preserved
Unit ...KeepsInheritedCleanupFailFast, GlobalCleanupCancellationKeepsMultipleGlobalCleanupFailFast
Removing the fail-fast handling would change which cleanups run
Summary: The fix lets global test cleanup run after a local cleanup cancellation while preserving the local failure and still honoring an active test deadline or run cancellation. The approach looks sound, with broad unit coverage and an acceptance test.
Findings (see inline comments):
The new CancellationTokenSource for global cleanup is never disposed.
The broad catch around global cleanup changes how exceptions propagate; the swallow-versus-surface behavior needs to be documented and tested.
The unit tests call the private ExecuteInternalAsync via reflection, which is brittle.
The acceptance asset writes an unused provenance file, and its Single() lookup is a fragility risk.
Test-value evidence: I did not execute the code, because the reviewer is read-only on untrusted PR code. The tests are statically predicted to fail without the fix, since the global cleanup would be skipped or cancelled. This was not verified by running them. Please attach red/green run evidence to the PR.
Not checked: I did not verify that the .xlf files are consistent. The diff adds no new resource strings, only reuses GlobalTestCleanupWasCancelled and TestCleanupWasCancelled.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Timeout-source renewal can let global cleanup outlive InvokeAsync without the whole-test deadline, risking incomplete resource release, while an unconditional source-generated test row fails when the supported opt-out is enabled.
Ports the cleanup-cancellation isolation fix from #12220 to main, addressing #6157 so local MSTest cleanup cancellation does not prevent independent global teardown.
Changes:
Renews a canceled context source at the global-cleanup boundary while preserving local failures and active cancellation budgets.
Adds unit coverage for token identity, deadline propagation, and cleanup fail-fast behavior.
Test-value evidence: Static inspection supports regression sensitivity. The description reports 139 unit and eight acceptance tests passing at 244fa660, with counterfactual failures before the rebase; execution artifacts were not independently verified here.
Address review feedback on timeout monitoring, cleanup exception aggregation, cancellation registration lifetime, and packaged regression coverage. Honor the source-generation opt-out and verify the loaded adapter against the shipping package.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Compared merge base 88a31ec394abe9f5c5dcf596f0a150ff998d3a0e with head 0a353eb74fdea1bb9fc1ac9887110dc7ba5e0b2c. Evidence applies to this head, not every intermediate commit.
Test-value evidence
All entries are static predictions. No paired red/green execution records were accessible, and this workflow does not run code.
Contract
Scenario / expected outcome
Test (decisive assertion)
Counterfactual
Evidence
Global cleanup still runs after local cleanup is cancelled or times out
Local cleanup cancels or times out. Global cleanup runs and the local failure is preserved.
Acceptance GlobalCleanupAfterLocalCancellationReleasesOwnedResource (event trace, owned-resource.txt absent, TRX message) and the GlobalCleanup*AfterLocalCancellation* unit tests
Old code cancelled the shared token source, so global cleanup would be skipped or cancelled. The trace and resource assertions should fail.
Static prediction: likely detected
Non-cooperative timeout waits for cleanup and keeps the original deadline
The test body times out or is cancelled, then cleanup runs. The deadline is not restarted and run cancellation is preserved.
NonCooperativeTimeout* and NonCooperativeBodyCancellation* unit tests; the NonCooperativeTest acceptance cases
Ablate CancelAfter(remainingTimeout), the run-cancellation propagation, or the cleanup wait. The deadline and cancellation tests should fail.
Static prediction: likely detected
Passed result is downgraded to Timeout if cancellation was requested
global-cancel-return produces a "was canceled" failure.
Acceptance TRX message assertion
Removing the downgrade should leave the outcome Passed and fail the assertions.
Static prediction: likely detected
Executed red/green evidence is unavailable. Ablating the source-generation variants and the synchronization-context dispatch fallback is not covered by a static check beyond the named tests.
🧵 Parallel safety
PARALLEL-SAFETY RESULT
STATUS: PARTIAL
The specialist run was not completed, so this is not a clean result. The changed acceptance class is [DoNotParallelize] and shares one generated asset. Its generated project declares [assembly: DoNotParallelize], and its evidence directories are per-test TempDirectory paths. I found no hazard in that class from reading it. The unit-test ranges were not analyzed for shared static state, so coverage there is incomplete.
Per-test assessment
Pseudo-mutation evidence consists of static predictions, not executed results. Per-test grading was done at the contract level, so the table below covers the acceptance test and one row for the new unit-test group.
Result
Quality
Test
Notes
How to improve
Pass
A (90–100)
new CleanupCancellationIsolationTests.GlobalCleanupAfterLocalCancellationReleasesOwnedResource
Asserts exact event trace, outcomes, resource release and messages per case.
None
Uncertain
—
new TestMethodInfoTests.GlobalCleanup* / NonCooperative* (about 29 methods)
Per-method bodies were not individually graded within the review budget.
Grade each method body against its production branch.
No inline findings were published. Existing-thread deduplication was not needed because no inline comments were queued.
<sub>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.</sub>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Active timeout-handling defects can interrupt resource cleanup after consumed run cancellation and misreport terminal cleanup cancellation as inconclusive rather than cancelled.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Monitor cancels cleanup after run cancellation is consumed
With a noncooperative whole-test timeout, run cancellation can finish during the body and the worker can enter fresh global cleanup before the monitor resumes. This branch cancels that renewed source even though cleanup deliberately excluded the already-consumed run cancellation, interrupting resource release; the linked wait at lines 197–199 also stops waiting on the consumed token. Share cleanup's cancellation-eligibility decision with both monitor paths, and add a rendezvous regression with run cancellation before cleanup entry.
Terminal cleanup cancellation is ignored for inconclusive tests
With a noncooperative whole-test timeout, an inconclusive body followed by a terminal cleanup that cancels its context and returns normally remains Inconclusive because this guard only handles Passed. That reports the test as skipped by default instead of recording cancellation. Include Inconclusive here and extend the terminal-cancellation regressions; the exception setter preserves the original failure alongside cancellation.
Serialize ordered inner failure details like modern .NET so local/global cleanup identities survive reporting. Retain the failing adapter assertion and add result-level and real net462 package-consumer regressions.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the default launcher unchanged and expose a per-call internal factory for ownership checks. Verify each real process is disposed exactly once and its native handle is closed, without a host-wide tolerance, forced GC, or scheduling changes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fixed the reported Windows Debug failures in b9f0e8d and b90b1a8.
Requirement
Evidence
Preserve cleanup method identities on .NET Framework
GlobalCleanupRetainsActiveTestDeadlineAfterLocalCancellation now passes unchanged on net462 and net48. The fix is in TestResult's serialized message capture, not a weaker assertion: .NET Framework's AggregateException.Message omits inner messages. Flat and nested failure details are now retained, while modern .NET formatting is unchanged.
Check actual failed-launch ownership
FailedLaunchDisposesProcessHandles now checks each of 12 real processes is disposed exactly once and its own valid native handle is closed. No higher tolerance, forced GC, retry, global factory, or scheduling change. The existing public launch API/default stays unchanged.
Validate shipped consumers
NetFrameworkCleanupFailureMessagesRetainBothMethodIdentities executes a real Release/net462 consumer and verifies its loaded framework hash and final TRX identity, outcome, and both cleanup errors. The source-only client also passed its default-language and hostile C# 12 consumer builds across net462, netstandard2.0 and net5.0 through net11.0.
Test-value evidence
Reproduced the reported cleanup failure on net462 before the fix. On the net48 framework host, the retained TestResultTests executed 15 cases: two intended message-loss failures and 13 passing controls.
The new packaged net462 test also failed against the original package at the intended assertion: the final TRX message was only One or more errors occurred. It passes with the rebuilt framework package.
The strengthened process-ownership test rejected a buildable missing-dispose fault with expected 1, actual 0, then passed after restoring the real source. The original host-wide count test was unchanged from main and passed three isolated local runs; those observations alone were not treated as proof of a real process leak or a retry-safe flake.
Final validation: cleanup class 152/152 net462, 152/152 net48, 154/154 net10.0; result tests 15/15 net48 and 15/15 net10.0; process class 40 Windows cases passed, with eight existing Unix-only skips; packed cleanup cases 13/13 passed; packed source-consumer cases 2/2 passed. All three reported failure configurations were rebuilt and rerun successfully at the final committed head.
Repacked all 22 product/acceptance prerequisites, including the source-client package, using the repository-pinned SDK 12.0.100-alpha.1.26509.101, Debug producers and Release generated consumers. Local binlogs, TRX, source patches, package snapshots and counterfactual results are retained. The final package tests ran at clean head b90b1a801ea89172972cb8081675c61f6adf79be.
Representative executed selectors (all fixed runs exited 0; $evidence only parameterizes the local results directory):
The four remaining open review threads already contain fix replies. I have not resolved them on the reviewers' behalf. This is local Windows validation; the newly triggered CI run is not yet claimed green.
Compared merge base 88a31ec394abe9f5c5dcf596f0a150ff998d3a0e with head b90b1a801ea89172972cb8081675c61f6adf79be. Evidence applies to this head, not every intermediate commit. Static review only; no code was built or executed.
Test-value evidence
Contract
Scenario / decisive test
Counterfactual
Evidence status
Global cleanup still runs after local cleanup is cancelled, and the original failure is preserved
TestMethodInfoTests.GlobalCleanupAfterLocalCancellation* and GlobalCleanupFailureDoesNotMask*; acceptance GlobalCleanupAfterLocalCancellationReleasesOwnedResource
Skip global cleanup after local cancellation, or let a global cleanup failure replace the local result
Static prediction: likely detected. No executed records.
Non-cooperative timeout and body cancellation keep the original cleanup deadline and run cancellation
NonCooperativeTimeout*, NonCooperativeBodyCancellation*, GlobalCleanupRetains* and GlobalCleanupDoesNotRestart*
Restart the deadline for renewed cleanup, or cancel renewed cleanup from the body cancellation
Static prediction: likely detected. No executed records.
Static prediction: likely detected. No executed records.
Executed red/green evidence is unavailable. Passing CI status is not treated as paired execution proof. The review covered the changed contracts in groups, not every one of the roughly 40 new test cases individually.
🧵 Parallel safety
STATUS: CLEAN, from a static read.
Test assembly
Scope
Workers
Analyzer coverage
MSTest.Acceptance.IntegrationTests
Assembly-level method parallelization (unchanged). The new class is [DoNotParallelize].
Unchanged
Not run
MSTestAdapter.PlatformServices.UnitTests
Internal TestContainer framework; no new shared state
Counts: Critical=0, High=0, Warning=0, Info=0. The generated asset writes only to per-test paths. The Probe/results.Path helpers were not checked beyond the changed ranges.
Per-test assessment
Pseudo-mutation evidence is static prediction only. It is not an executed mutation result.
Per-method grading was not completed for this head because the PR adds roughly 40 new test methods. The scorecard below is therefore partial: it lists only the representative grouped rows, and the remaining new tests are ungraded (not Pass). I found no verified defects that warranted an inline comment. Prior reviews on earlier commits raised the same areas, so I added no duplicate threads.
Result
Quality
Test
Notes
How to improve
Uncertain
—
new TestMethodInfoTests cleanup and timeout group (about 30 methods)
Not graded individually; the production timeout and cleanup state machine is intricate.
Per-method grading with executed red/green runs would resolve this.
Uncertain
—
new CleanupCancellationIsolationTests.GlobalCleanupAfterLocalCancellationReleasesOwnedResource
Not individually graded; static read shows an owned-resource assertion.
Confirm with an executed run on this head.
Uncertain
—
mod MtpServerProcessTests.FailedLaunchDisposesProcessHandles
Per-launch disposal check replaces the ambient handle-count delta.
Confirm with an executed run on this head.
Uncertain
—
new TestResultTests.SettingTestFailureExceptionShouldPreserveNestedAggregateMessages
Not individually graded.
Assert each nested message string exactly.
<sub>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.</sub>
Final test-triage resolution — Azure Pipelines build 1667585
Result: inconclusive (evidence incomplete: one artifact download failed and the history download budget was exhausted). No issue was created.
Affected leg: Windows Release, task "Test affected changes". It exited with code 2.
Failure signatures
TestMethodInfoTests.NonCooperativeTimeoutWaitsForGlobalCleanupAfterLocalCancellation on .NET Framework 4.8 (TestMethodInfoTests.cs:3653).
The assertion expected the Task<bool> to be WaitingForActivation, with the message "Timed out waiting for background invocation cleanup". It found a Task+DelayPromise with status Canceled.
This is a deterministic-looking assertion mismatch, not a runner or infrastructure error. It exercises the behavior this PR changes (global cleanup after local cancellation). Confidence: high that it is related to this PR.
Next step: reproduce on net48 and check whether the delay task is canceled by the local cancellation token. If so, either the production change or the test's expectation needs adjusting.
SystemWrappersTests.Environment_ExitAndFailFastAreConfinedToOwnedChild ("fail-fast" and "fail-fast-exception" cases, net462) failed with System.TimeoutException: The operation has timed out.
This is likely an environmental or timing issue, but confidence is low. No history match was found, and the history is incomplete.
Next step: rerun the leg. If it recurs on an unrelated commit, open an issue.
Other signals
Retry-probe tests (RetryFailsFirstAttempt, RetryTestMethod_PassesOnSecondAppContainerHost) and NativeTests.Outcome ("expected host failure") are deliberate failures from app-model diagnostics assets. They are not product defects.
No crash or hang diagnostics were found. No slowness regressions were found.
Searching open and closed issues found no existing issue for these test names.
🤖 Automated content by GitHub Copilot. Generated by the Pipeline Test Triage workflow. · copilot · auto · ~28 AIC · ⌖ ~1 AIC · ⊞ 10K
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
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.
Pull request
Summary
Port the cleanup-cancellation isolation fix from merged #12220 (
rel/4.5) tomain. Relates to #6157; the broader initialization/lifetime discussion remains open.A cooperative timeout or explicit cancellation in local
TestCleanupmust not prevent independentGlobalTestCleanupfrom entering solely because the same context cancellation source was poisoned. Renew that source only at the global-teardown boundary while retaining the original failure, active whole-test/run cancellation budgets, and inherited-local/multiple-global fail-fast rules.No public/internal API, default-timeout, or healthy-path token-identity changes. The initial port matched the approved lifecycle/test source. Review follow-ups additionally preserve noncooperative cleanup completion within the whole-test budget, report secondary global cleanup failures, and honor the source-generation opt-out.
Design and decision record
This is a bounded bug fix, not a new feature. The investigation and decision on #6157 and merged #12220 are the maintained rationale; no separate feature RFC is needed.
Keep the existing initializer cancellation guard. Do not reset the token before every lifecycle call: doing so can lose already-delivered cancellation or restart a test deadline. Capture local failure before global teardown, preserve cancellation even when local cleanup returns normally, and re-register only budgets still active at cleanup entry against the renewed source. Budgets consumed before cleanup retain the existing fresh-teardown policy.
Review follow-up: fixture cancellation during claimed cleanup must not stop the whole-test monitor. The monitor has its own cancellation signal and an owned deadline source that remains alive until both the monitor and invocation finish. Deadline/run cancellation reaches renewed cleanup sources without restarting the budget. Local/global failures are appended through
TestResult's ordered aggregation; a local timeout keeps its classification, while an independent global failure cannot leave an inconclusive result. The live context source remains usable after cleanup, consistent withTestContext's existing ownership policy; its cancellation registrations are scoped.Demonstration
The change is nonvisual lifecycle/resource behavior; a trace is clearer than a screenshot:
The unrelated-local-exception control already ran global cleanup before the fix. The acceptance fixture checks both
NoBaseTestandWithBaseTest, exact TRX identity/class/outcome association, full traces and resource removal; a separate case actually executes source-generated metadata.Validation and regression proof
Previously validated port head:
244fa660c66690bbc9a6704978042671dc6a515b, based on88a31ec394abe9f5c5dcf596f0a150ff998d3a0e. The following original-port evidence is historical; current review-fix evidence is recorded below. Repository-pinned SDK12.0.100-alpha.1.26509.101, Windows x64, Debug producers; real net10 package consumers are built in Release. The SDK-current outer acceptance host is net12.TestMethodInfoTests: 139 executed/passed, 0 failed/skipped, exit 0.CleanupCancellationIsolationTests: 8 executed/passed, 0 failed/skipped, exit 0, including actual source-generated metadata. The repository execution gate independently reconciled all eight expected case names/counts.37DF33D91E4408A976E9E3C05D462D97871CD444F73B23B5C33FFB93C7FE801F; loaded DLL SHA-256:DABB54357194BDCA013EB68F88A884677DE19C2530590E6AA9B96EB2C2E9331C. The nupkg repository commit is this exact head.Exact functional selectors/arguments (machine-local result/binlog roots are parameterized as
$evidence):Build/pack properties:
-c Debug --no-restore -v minimal -nodeReuse:false -p:TreatWarningsAsErrors=true -p:MSBuildTreatWarningsAsErrors=true -p:SkipUapTargetFramework=true -p:SupportedNetFrameworks=net10.0 -p:ModernUwpMinimum= -p:WinUiMinimum=, with a unique quoted-blargument per invocation. The unit build additionally selects-f net10.0. Actual current-main packages are rebuilt with those properties before the acceptance run; old same-version caches are not used as proof.The build/pack command forms below all passed with exit 0;
$commonis the exact shared property set above and$evidenceparameterizes only the machine-local artifact root:The same per-project pack form also rebuilt the actual eager acceptance prerequisites (analyzers, platform MSBuild integration, TRX/abstractions, telemetry, configuration, hosting, logging, OpenTelemetry, CTRF, JUnit, GitHub Actions, PackagedApp, retry, video and Azure Foundry); this is not a claimed whole-repository/UAP package-inventory pass.
The named packed cases are
GlobalCleanup_Normal,GlobalCleanup_UnrelatedLocalFailure,GlobalCleanup_LocalCancellationWithoutException,GlobalCleanup_LocalCancellationException,GlobalCleanup_CancellationWithUnrelatedLocalFailure,GlobalCleanup_LocalCooperativeTimeout,GlobalCleanup_PreservesLocalTimeoutWhenGlobalCleanupThrows, andGlobalCleanup_LocalCooperativeTimeout_SourceGeneration.Local logs/TRX and payload-hash manifests are retained; no public artifact upload or CI pass is claimed. This is focused MTP reflection/source-generation validation, not a full OS/TFM/UAP matrix or an independent VSTest pass. The original optional VSTest probe had the same zero-test framework-loader mismatch with original and fixed packages; it was not counted as behavioral evidence or expanded into an unrelated packaging change.
Test-value evidence
GlobalCleanup*unit regressionsCleanupCancellationIsolationTestscasesThe prior main evidence is bound to original commit
e0ce525219a1e10bcce8d2b3ab048b03ac26b495(base92e83edafb54811009aae479caf29a763f19a99aplus the recorded test patch). All three approved source/test blobs are byte-identical after rebase; current unit/shipping green validation is reported separately rather than presenting the earlier red run as a new run on the rebased head. Merged #12220 independently reproduced the same release-bound red/green behavior.Review-fix revision and test-value evidence
Current review revision:
99e4e2dd546269b34c1310485bfd196f9f774c72, directly based on244fa660c66690bbc9a6704978042671dc6a515b. Windows x64, pinned SDK12.0.100-alpha.1.26509.101, runtime10.0.14, Debug producers/outer hosts and Release net10 consumers. All 21 product/acceptance prerequisite packages were repacked at this revision with compiler/MSBuild warnings as errors.NonCooperativeTimeoutWaitsForGlobalCleanupAfterLocalCancellation,NonCooperativeTimeoutOnSynchronizationContextWaitsForGlobalCleanupAfterLocalCancellation,NonCooperativeTimeoutCancelsRenewedGlobalCleanupAtOriginalDeadlineInvokeAsync, thread operations/dispatcher, and bounded worker joins.GlobalCleanupFailureDoesNotMaskLocalCancellation,GlobalCleanupFailureDoesNotMaskLocalUnrelatedFailureAfterCancellation,GlobalCleanupFailureDoesNotMaskUncancelledLocalFailure,GlobalCleanupFailureFailsInconclusiveLocalCleanupGlobalCleanup_PreservesLocalTimeoutWhenGlobalCleanupThrows,GlobalCleanup_LocalCooperativeTimeout_NonCooperativeTest,GlobalCleanup_LocalCooperativeTimeout_NonCooperativeTest_SourceGenerationGlobalCleanupRenewedSourceRemainsUsableAfterInvocation; typedInvokeWithTestDeadlineAsynchelperGlobalCleanupAfterLocalCancellationReleasesOwnedResource/CleanupCasesMSTEST_ACCEPTANCE_SKIP_SOURCEGEN=1andtrueeach discover/execute/pass exactly eight reflection cases, zero failed/skipped. With the opt-out unset, all ten cases pass, including both source-generation rows.Final unit selection: 146 executed, 146 passed, zero failed/skipped, exit 0. The same retained unit selection against the original implementation executed 146 cases with seven intended failures and 139 controls passed, exit 2. The retained final test patch SHA-256 is
C167BCB71EDA99D24AF056036D399B58DDA92A475836A66F558D60CA1F5EB736.Final packed selection: 10/10 passed with source generation enabled, 8/8 passed for each opt-out value, all outer exits 0 and no skips. Original packed selection: 10 executed, three intended assertion failures and seven controls passed, exit 2. Failing child tests remain intentional (child exit 2); the outer checks assert the correct preserved failures rather than accepting a false success.
The fixture now reads and asserts
product-provenance.txt, reports explicit loaded-assembly-count failures instead of an opaqueSingle()failure, and sets childDOTNET_CLI_UI_LANGUAGE=en-US. All 52 final child adapter loads matched the current nupkg payload. Adapter packageMSTest.TestAdapter.5.0.0-dev.nupkgSHA-256:144329172D902BA9A60A97FB550A34412BBC578FE564786CB49058D198BC6E86; loaded platform-services DLL SHA-256:ACC8555FB59347354A0DF000542EFD01DEC42DD7EBC55CC2684E060E4CA19FDC. Its nupkg repository commit equals this exact review revision. The original packed comparison used package SHA-25612C5153E9D4D589766F0850FE152C69780A9D47EB5D0406A82D246A83026C6A7/ loaded DLLB9029F9D48C898C15907A6D28428CBD64592597A050B2EBFA50CDB87B29675F4.Exact final command forms, all passed / exit 0 (
$evidenceparameterizes only the local evidence directory):The same per-project pack form rebuilt the other 20 prerequisite packages already enumerated above; no whole-repository/UAP inventory pass is claimed. The repository execution gate independently reconciled each source-declared plan with its fresh outer TRX and exit. Logs, TRX, package hashes and resolved consumer assets are retained locally; the concise assertion excerpts/counts above are the published evidence, not an invented artifact URL.
This is nonvisual lifecycle behavior; executable traces and final TRX/resource assertions are more useful than staged screenshots. Validation is focused Windows net10 reflection/rooting-source-generation coverage, not a full OS/TFM/VSTest/AOT matrix. CI has not been awaited. These review fixes target main only; merged #12220 on
rel/4.5was not modified, so any corresponding servicing/backport needs remain separate.