Skip to content

Reduce redundant acceptance test preparation - #12197

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/acceptance-test-efficiency
Nov 4, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/acceptance-test-efficiency

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Pull request

Summary

Acceptance setup was creating a temporary asset root that was immediately abandoned, and two fixtures were compiling target frameworks that none of their assertions executed.

Remove the unused constructor delegation in TestAsset and limit the ANSI and assembly-cleanup fixtures to the NetCurrent TFM they consume. Add regressions for a single owned preparation root, independent same-name assets, and borrowed-directory ownership. No existing test, data row, launch or assertion is removed.

Design and decision record

This is a bounded test-infrastructure fix, not a new feature requiring a separate design record. The consumer inventory showed that every ANSI and assembly-cleanup assertion launches only NetCurrent in Release/reflection mode. Both their reflection and default Rooting source-generation builds remain.

Keep the existing fixture lifetime, private mutable assets, fresh per-assembly package caches, compiler sharing and method-level parallel scheduling. Do not introduce global build caching or merge the four materially different Runner scenarios.

Demonstration

Measured with the same 97 existing acceptance cases, using generated-root inventories and complete child binlogs:

Work Before After
Csc executions in the two fixtures, reflection + Rooting 20 4
Preparation roots 163 83
Bootstrap file writes 652 332
Child build/publish invocations 84 84

All 80 Runner combinations remain: five TFMs x Debug/Release x build/publish x four scenarios. These measurements use the full local Windows matrix; CI's FastAcceptanceTest=true matrix starts smaller. No wall-time speedup is claimed from a single noisy comparison. Media is not applicable because product output/layout is unchanged.

Validation and regression proof

Validated source bytes are committed as 98ecc720fc67e63c281af8712170185b84853eb4; execution occurred before committing, with all four files verified byte-for-byte unchanged afterward. Baseline: d9e38dc463365dc12f714db14815b46dedb0ed15.

Windows x64, pinned SDK 12.0.100-alpha.1.26509.101, Release/net12.0 outer hosts. .\build.cmd -pack -c Release -bl passed on both source states, exit 0, with 0 warnings/errors. An intermediate pack exhausted local disk space; the unchanged retry passed after owned cleanup.

Executed test commands from the worktree root, with equivalent fresh output paths below instead of the original machine-specific locations:

$mtp = 'test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj'
$mstest = 'test\IntegrationTests\MSTest.Acceptance.IntegrationTests\MSTest.Acceptance.IntegrationTests.csproj'
$results = Join-Path (Get-Location) ('artifacts\TestResults\Release\acceptance-efficiency-' + [Guid]::NewGuid().ToString('N'))
$mtpResults = Join-Path $results 'mtp'
$mstestResults = Join-Path $results 'mstest'
$helperResults = Join-Path $results 'helpers'
New-Item -ItemType Directory -Path $mtpResults, $mstestResults, $helperResults -Force | Out-Null
$common = @('-c', 'Release', '-p:UsingDotNetTest=true', '-p:EnableCodeCoverage=false',
    '-p:TestRunnerAdditionalArguments=', '--show-test-results', 'all', '--no-ansi', '--no-progress')

# Exit 0: 16 passed, 0 failed/skipped.
& .\.dotnet\dotnet.exe test --project $mtp @common "-p:ArtifactsTestResultsDir=$mtpResults" "-bl:$mtpResults\outer.binlog" --filter 'FullyQualifiedName~Microsoft.Testing.Platform.Acceptance.IntegrationTests.AnsiOptionTests|FullyQualifiedName~Microsoft.Testing.Platform.Acceptance.IntegrationTests.TestAssetEncodingTests'

# Exit 0: 81 passed, 0 failed/skipped.
& .\.dotnet\dotnet.exe test --project $mstest @common "-p:ArtifactsTestResultsDir=$mstestResults" "-bl:$mstestResults\outer.binlog" --filter 'FullyQualifiedName~MSTest.Acceptance.IntegrationTests.AssemblyCleanupTests|FullyQualifiedName~MSTest.Acceptance.IntegrationTests.RunnerTests'

# Exit 0: 4 passed, 0 failed/skipped.
& .\.dotnet\dotnet.exe test --project $mtp @common "-p:ArtifactsTestResultsDir=$helperResults" "-bl:$helperResults\outer.binlog" --filter 'FullyQualifiedName~Microsoft.Testing.Platform.Acceptance.IntegrationTests.TestAssetTests|FullyQualifiedName~Microsoft.Testing.Platform.Acceptance.IntegrationTests.TestAssetEncodingTests'

The first two selectors also passed before the changes (16 + 81, using --no-build after the baseline pack). Final commands rebuilt the affected projects. Final totals: 101 passing executions / 100 distinct cases, because the existing encoding control is intentionally repeated in the helper selection. Independent native-SDK discovery reconciled 19 MTP and 81 MSTest cases. Fresh TRX identities/counters passed the repository execution verifier; JUnit and CTRF exports also parsed with matching counts.

Generated consumers used the real Release packages: MTP 2.6.0-dev and MSTest 4.6.0-dev. The relevant platform/framework/adapter/source-generation archives were byte-identical across states; 382 baseline and 350 final physical consumer DLL copies matched their exact archive payloads. Raw local reports/binlogs and package/source manifests are retained but are not publicly uploaded; the observable results are summarized here.

Full-suite CI, Linux/macOS, and unrelated native AOT/ReflectionFree/platform-specific runtime tests were not run locally; their source and mode matrices are unchanged. Rooting preparation in the two changed fixtures is compile proof, not a claim that those fixtures execute source-generated metadata.

Test-value evidence

Contract / case Without the change With the change
GenerateAssetAsync_WithoutDirectory_PreparesOnlyTheOwnedRoot Executed against the actual pre-fix helper with the new tests retained: Assert.HasCount(1, preparedRoots) failed, expected 1 / actual 2. Same helper selector above with --no-build after compiling the additive tests: exit 2, 3 passed / 1 failed / 0 skipped. Identical test bytes and selector: exit 0, 4 passed / 0 failed/skipped.
Private/borrowed asset ownership Controls passed before the fix. GenerateAssetAsync_WithSameName_KeepsAssetsIndependent and Dispose_WithBorrowedDirectory_LeavesCallerOwnedFiles passed, checking distinct paths/contents and post-disposal caller files.
Fixture behavior preservation All 97 selected existing cases passed. The same 97 cases passed with unchanged assertions; compiler work was measured separately rather than inferred from reflection runtime results.

Avoid creating an abandoned temporary root for owned assets, prepare only consumed TFMs in the ANSI and assembly-cleanup fixtures, and add asset ownership regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 09:07
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Nov 4, 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 4, 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 4, 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 #12197

Compared merge base d9e38dc463365dc12f714db14815b46dedb0ed15 with head 98ecc720fc67e63c281af8712170185b84853eb4. Evidence applies to this head, not every intermediate commit. No inline findings. Duplicate-report lookup was not performed.

Test-value evidence

Nothing was executed in this review. The results below are static predictions, plus the PR author's own claims, which I have not verified.

Contract Test and decisive assertion Counterfactual Evidence
TestAsset(name, code) owns only one root, with no abandoned temp root. GenerateAssetAsync_WithoutDirectory_PreparesOnlyTheOwnedRoot: Assert.HasCount(1, preparedRoots). Restoring the : this(assetName, assetCode, new TempDirectory(null)) delegation creates a second root containing the asset directory, so the count would be 2. Static prediction: would fail on the old code and pass on the fix. The PR claims an executed red/green run (expected 1, actual 2). That run is not independently verifiable here.
Same-name owned assets stay independent. GenerateAssetAsync_WithSameName_KeepsAssetsIndependent: distinct paths, and contents first / second. Sharing one root would collide or overwrite. Static prediction. The test is a control that passes before and after.
A borrowed directory is not deleted on Dispose. Dispose_WithBorrowedDirectory_LeavesCallerOwnedFiles: Caller.txt and Data.txt remain after Dispose. Disposing the caller's directory would delete both files. Static prediction. The test is a control that passes before and after.
ANSI and assembly-cleanup fixtures prepare only NetCurrent. Existing tests all call LocateFrom(..., TargetFrameworks.NetCurrent). A consumed-TFM mismatch would fail at host location. Refactor, expected green before and after. I checked that the static consumers use NetCurrent. The author reports 97 existing cases passing before and after.

Gap: no accessible execution records were available to me. The numbers above come from the PR description.

🧵 Parallel safety

STATUS: CLEAN (counts all 0).

Assembly Scope
Microsoft.Testing.Platform.Acceptance.IntegrationTests MethodLevel, all cores.
MSTest.Acceptance.IntegrationTests The changed file was treated as in scope, but no parallelization attribute changed. Settings were not inspected.

TestAssetTests uses GUID-suffixed asset names, so enumerating TestSuiteDirectory can only match its own root. No findings.

Per-test assessment

Pseudo-mutation evidence below consists of static predictions, not executed mutation results.

<table>
<thead>
<tr><th>Result</th><th>Quality</th><th>Test</th><th>Notes</th><th>How to improve</th></tr>
</thead>
<tbody>
<tr>
<td>Pass</td>
<td>A (90–100)</td>
<td>new <code>TestAssetTests.<br>GenerateAssetAsync_<br>WithoutDirectory_<br>PreparesOnlyTheOwnedRoot</code></td>
<td>Asserts exactly one prepared root, the path, the id, the contents and the NuGet.config.</td>
<td>None</td>
</tr>
<tr>
<td>Pass</td>
<td>B (80–89)</td>
<td>new <code>TestAssetTests.<br>GenerateAssetAsync_<br>WithSameName_<br>KeepsAssetsIndependent</code></td>
<td>Distinct paths and per-asset contents are verified.</td>
<td>None</td>
</tr>
<tr>
<td>Pass</td>
<td>B (80–89)</td>
<td>new <code>TestAssetTests.<br>Dispose_<br>WithBorrowedDirectory_<br>LeavesCallerOwnedFiles</code></td>
<td>Caller and asset files survive disposal.</td>
<td>None</td>
</tr>
</tbody>
</table>

The modified fixtures in AssemblyCleanupTests and AnsiOptionTests contain no changed test methods, so they are not graded.

<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>

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · ~47 AIC · ⌖ ~1 AIC · ⊞ 8K

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 4, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 4, 2026

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.

🟢 Approval recommended

No active review issues remain for the targeted reduction in redundant acceptance-test preparation.

No open issues 🎉

What changed in this PR

This PR reduces redundant acceptance-test preparation in the shared test infrastructure without changing the existing execution matrix or assertions.

Changes:

  • Removes constructor delegation that creates an abandoned temporary asset root.
  • Limits ANSI and assembly-cleanup fixture preparation to the NetCurrent framework their tests execute.
  • Adds regressions for single-root preparation, independent same-name assets, and borrowed-directory ownership.

Test-value evidence: For revision 98ecc720, the PR reports the new root-count regression failing before the fix and passing afterward, plus all 97 existing selected cases passing on both states. Execution artifacts were not independently inspected; cross-platform and full-suite validation remain outside the reported local run.

File Description
test/​Utilities/​Microsoft.Testing.TestInfrastructure/​TestAsset.cs Removes redundant temporary-root creation.
test/​IntegrationTests/​MSTest.Acceptance.IntegrationTests/​AssemblyCleanupTests.cs Prepares only the framework consumed by the test.
test/​IntegrationTests/​Microsoft.Testing.Platform.Acceptance.IntegrationTests/​TestAssetTests.cs Adds preparation and ownership regression tests.
test/​IntegrationTests/​Microsoft.Testing.Platform.Acceptance.IntegrationTests/​AnsiOptionTests.cs Restricts fixture preparation to NetCurrent.

Review effort: Balanced

@Evangelink
Amaury Levé (Evangelink) merged commit fe8a985 into main Nov 4, 2026
30 of 35 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/acceptance-test-efficiency branch November 4, 2026 09:18
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Nov 4, 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.

3 participants