Skip to content

[ResourceLock] Replace class-level DoNotParallelize with ResourceLock in TrxLongPathHelperTests - #10718

Open
Amaury Levé (Evangelink) wants to merge 17 commits into
mainfrom
resource-lock/testing-extensions-unittests-37f35029886f7421
Open

[ResourceLock] Replace class-level DoNotParallelize with ResourceLock in TrxLongPathHelperTests#10718
Amaury Levé (Evangelink) wants to merge 17 commits into
mainfrom
resource-lock/testing-extensions-unittests-37f35029886f7421

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

  • In the method-level-parallelized Microsoft.Testing.Extensions.UnitTests project, replace the class-level [DoNotParallelize] on TrxLongPathHelperTests with [ResourceLock(WellKnownResources.CurrentDirectory)].
  • Both test methods mutate the process-wide current directory and restore the original value in finally; the class-level lock is reacquired for each method and serializes those conflicting mutations without suppressing unrelated parallel tests.
  • Clarify the class remarks to document why the narrower lock is sufficient.

Validation

  • bash ./build.sh — succeeded with 0 errors and 0 warnings.
  • The test class is guarded by #if !NETCOREAPP and therefore only builds for net462/net472, which could not run on the Linux workflow runner. A net8.0 --filter-uid probe confirmed that no matching tests are compiled for that target framework.

Recovered from the safe-output failure in https://github.com/microsoft/testfx/actions/runs/32812234406.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 25, 2026 07:41
@Evangelink Amaury Levé (Evangelink) added type/tech-debt Code health, refactoring, simplification. type/automation Created or maintained by an agentic workflow. labels Aug 25, 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.

Pull request overview

Replaces broad test parallelization suppression with a current-directory resource lock.

Changes:

  • Applies WellKnownResources.CurrentDirectory.
  • Documents lock scope and directory restoration.
Show a summary per file
File Description
TrxLongPathHelperTests.cs Narrows current-directory synchronization.

Review details

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

/// </remarks>
[TestClass]
[DoNotParallelize]
[ResourceLock(WellKnownResources.CurrentDirectory)]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 5d2cef9. StackTraceSourceLocationResolverTests now takes a read lock on WellKnownResources.CurrentDirectory, so its readers coordinate with the writer lock in TrxLongPathHelperTests. The focused net462 run passed all 9 affected tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8e062c95-4074-40aa-979a-f1f3563d30c3
Copilot-Session: 9b40ad18-2680-4d54-b965-8cf41c6df384
Copilot-Session: 6babe228-0d10-48a1-84c8-583f7ff56281
Copilot-Session: daf71962-ce66-4366-8ba6-700a2f0829bf
…: Build ID 3056930 (#10725)

Co-authored-by: dotnet-oneloc-localization[bot] <310689744+dotnet-oneloc-localization[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c661d151-50e8-4112-be24-c3144a02580e
Copilot-Session: 64fbc2fa-0f15-4789-b4c9-6c74e6b4c925
Copilot-Session: 05d06302-12f7-4db0-a3a7-8923510820f9
…10731)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…10640)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Amaury Levé <amauryleve@microsoft.com>
Copilot-Session: 021b7d71-92b8-40a1-a0ab-5a6d768c5b1a
Copilot-Session: fc14aba1-535f-404f-b2c2-56475e3ace7c
Add a read lock to StackTraceSourceLocationResolverTests so it cannot observe temporary current-directory mutations from TrxLongPathHelperTests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 25, 2026 16:19
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review August 25, 2026 16:19
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Expert test review — PR #10718

No new or modified test methods were identified in the changed regions of this PR. The only diff hunk touches the class-level XML <remarks> documentation and swaps [DoNotParallelize] for [ResourceLock(WellKnownResources.CurrentDirectory)] on TrxLongPathHelperTests; neither test method's signature, attributes, or body fall within the changed lines. Nothing to review.

Re-run with /review-tests.

🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 61.6 AIC · ⌖ 0.922 AIC · ⊞ 16.9K · [◷]( · )

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

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Scope note: The diff shows 119 changed files / ~3700 additions, but the PR's own unique changes (commits 64d4964 and 5d2cef9) touch only 2 test files. The rest is from merging main into the branch. This review covers the PR-specific changes:

  1. TrxLongPathHelperTests.cs — Replaces [DoNotParallelize] with [ResourceLock(WellKnownResources.CurrentDirectory)] (write mode, the default). Remarks updated to explain the narrower serialization. Correct: both test methods mutate and restore the current directory in finally blocks, so a per-method resource lock serializes the mutations without suppressing unrelated parallel tests.

  2. StackTraceSourceLocationResolverTests.cs — Adds [ResourceLock(WellKnownResources.CurrentDirectory, Mode = ResourceAccessMode.Read)]. Correct: this class reads the current directory (via relative path resolution) and would be affected by concurrent mutations from TrxLongPathHelperTests. The read lock serializes against writers while still allowing other readers to run in parallel.

Both changes are well-motivated, correctly scoped, and the #if !NETCOREAPP guard on the TRX tests means there is no cross-TFM risk on .NET Core/5+. The class is only compiled for net462/net472.

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.

Review details

  • Files reviewed: 119/119 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread Directory.Packages.props
_ValidateBundledSdkFeatureVersions target (in Directory.Build.targets) fails the build if
the two drift apart. -->
<AspireHostingTestingVersion>13.4.6</AspireHostingTestingVersion>
<AspireHostingTestingVersion>13.5.2</AspireHostingTestingVersion>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/automation Created or maintained by an agentic workflow. type/tech-debt Code health, refactoring, simplification.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants