Enable safe parallelization for task test projects - #55992
Open
Evangelink wants to merge 1 commit into
Open
Conversation
Run the audited task test projects at class-level parallel scope and serialize classes that mutate process-wide current directory or environment state. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
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.
Copilot review overview
Review tier: Lite
Findings: None
What changed in this PR
This PR enables conservative MSTest class-level parallel execution for several task-focused test projects, and adds targeted serialization via [ResourceLock] for tests that mutate process-global state (current directory / environment variables) to keep parallel runs isolated.
Changes:
- Enable
MSTestParallelizeScope=ClassLevelin four MSTest test projects. - Add
[ResourceLock(WellKnownResources.CurrentDirectory)]to test classes that callDirectory.SetCurrentDirectory(...). - Serialize the publish environment-variable test with
[ResourceLock(WellKnownResources.EnvironmentVariables)]and restore the original value viatry/finally.
| File | Description |
|---|---|
| test/sdk-tasks.Tests/sdk-tasks.Tests.csproj | Opt into MSTest class-level parallelization. |
| test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Microsoft.NET.Sdk.Publish.Tasks.Tests.csproj | Opt into MSTest class-level parallelization. |
| test/Microsoft.NET.Sdk.Publish.Tasks.Tests/EnvironmentHelperTests.cs | Serialize env-var mutation and restore original value reliably. |
| test/Microsoft.NET.Build.Tasks.Tests/Microsoft.NET.Build.Tasks.Tests.csproj | Switch from assembly-serial execution to class-level parallelization. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenTasksUseAbsolutePaths.cs | Serialize CWD-mutating test class via WellKnownResources.CurrentDirectory. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAWriteAppConfigWithSupportedRuntimeMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenATaskEnvironmentDefault.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAResolveRuntimePackAssetsTask.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAResolvePackageFileConflictsMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAResolvePackageAssetsMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAResolveAppHostsMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAPickBestRidMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAGetPackagesToPrune.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAGenerateRuntimeConfigMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAGenerateDepsFileMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAGenerateClsidMapMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenAGenerateBundleMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Tasks.Tests/GivenACheckForUnsupportedWinMDReferencesMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
| test/Microsoft.NET.Build.Extensions.Tasks.Tests/Microsoft.NET.Build.Extensions.Tasks.Tests.csproj | Opt into MSTest class-level parallelization. |
| test/Microsoft.NET.Build.Extensions.Tasks.Tests/GivenAGetDependsOnNETStandardMultiThreading.cs | Serialize CWD-mutating test class via resource lock. |
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.
These task-focused MSTest projects currently run serially even though most test classes do not share mutable state. Enabling conservative class-level parallelism should reduce execution time while preserving isolation for the small set of process-global resources.
Changes
ClassLevelparallelization in four task test projects.WellKnownResources.CurrentDirectory.finallyblock.No
DoNotParallelizeexclusions are needed because the resource locks cover the complete affected class lifecycle without blocking unrelated classes.Testing
Local test and benchmark runs were intentionally deferred so the parallelization changes can be measured together in one consolidated 10-run baseline and changed fleet benchmark.