Skip to content

Parallelize additional MSTest unit suites - #55964

Merged
Evangelink merged 6 commits into
mainfrom
dev/amauryleve/parallel-unit-test-pr
Aug 28, 2026
Merged

Evangelink merged 6 commits into
mainfrom
dev/amauryleve/parallel-unit-test-pr

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

  • Enable MSTest method-level parallelization for the ApiDiff and ApiCompatibility unit test projects.
  • Enable MSTest class-level parallelization for Microsoft.DotNet.Cli.Utils.Tests, TemplateEngine Core unit tests, and TemplateEngine Orchestrator RunnableProjects unit tests, preserving isolation between methods that share class-scoped state.
  • Harden test isolation by removing shared log state, protecting assembly emission with ResourceLock, restoring ambient cultures, virtualizing environment-variable access, and isolating Template Engine host identifiers.

Test evidence

Validated on the creator branch before extracting this reviewable tranche:

Project Result
Microsoft.DotNet.Cli.Utils.Tests 236 cases passed repeatedly; warm runtime improved from 69.5s to 46.6s
ApiDiff 173 total: 170 passed, 3 skipped
ApiCompatibility 246 passed
TemplateEngine Core Both target frameworks: 363 total, 362 passed, 1 skipped
TemplateEngine Orchestrator RunnableProjects net11.0: 511 total, 509 passed, 2 skipped; net481: 500 total, 498 passed, 2 skipped

Evangelink and others added 5 commits August 27, 2026 14:04
Enable class-level MSTest parallelism while removing process-wide environment mutations and restoring test culture changes.

Co-authored-by: Copilot App <[email protected]>
Copilot AI lite review requested due to automatic review settings August 27, 2026 12:06
@Evangelink
Evangelink requested review from a team as code owners August 27, 2026 12:06
@azure-pipelines

Copy link
Copy Markdown
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.

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

This PR enables additional MSTest parallel execution across several unit test projects and adjusts specific tests to improve isolation under concurrent execution (culture restoration, log isolation, environment-variable virtualization, and targeted serialization via ResourceLock).

Changes:

  • Opts specific test projects into MSTest parallelization (MethodLevel for ApiDiff/ApiCompatibility; ClassLevel for several TemplateEngine and CLI util test suites).
  • Restores ambient CultureInfo.CurrentCulture (and wraps TemplateEngine environment creation to avoid leaking CurrentUICulture) in culture-sensitive tests.
  • Hardens ApiCompatibility tests by removing shared log instances and serializing assembly emission with [ResourceLock].
Show a summary per file
File Description
test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/FirstUpperCaseValueFormTests.cs Restores CurrentCulture around culture-dependent value-form assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/FirstUpperCaseInvariantValueFormModel.cs Restores CurrentCulture around invariant value-form assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/FirstLowerCaseValueFormTests.cs Restores CurrentCulture around culture-dependent value-form assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/FirstLowerCaseInvariantValueFormTests.cs Restores CurrentCulture around invariant value-form assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests.csproj Enables class-level MSTest parallelization for the RunnableProjects unit tests.
test/TemplateEngine/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/BindSymbolTests.cs Removes process-level environment mutation and introduces a helper for virtualized env-var access.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/VariablesTests.cs Routes environment creation through shared helper to avoid leaking ambient culture state.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs Adds helper that restores CurrentUICulture after creating TemplateEngine test environments.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/SetFlagTests.cs Uses the new environment-creation helper for isolation.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ReplacementTests.cs Uses the new environment-creation helper for isolation.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/RegionTests.cs Uses the new environment-creation helper for isolation.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/OrchestratorTests.cs Uses the new environment-creation helper and updates test base type.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/Microsoft.TemplateEngine.Core.UnitTests.csproj Enables class-level MSTest parallelization for the TemplateEngine Core unit tests.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/LookaroundTests.cs Uses the new environment-creation helper for isolation.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.CStyleEvaluator.cs Restores CurrentCulture around culture-dependent conditional processing assertions.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ConditionalTests.cs Routes environment creation through shared helper to avoid leaking ambient culture state.
test/TemplateEngine/Microsoft.TemplateEngine.Core.UnitTests/ChunkStreamReadTests.cs Uses the new environment-creation helper for isolation.
test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj Enables class-level MSTest parallelization for CLI utils tests.
test/Compatibility/ApiDiff/Microsoft.DotNet.ApiDiff.Tests/Microsoft.DotNet.ApiDiff.Tests.csproj Enables method-level MSTest parallelization for ApiDiff tests.
test/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompatibility.Tests/Rules/AssemblyIdentityMustMatchTests.cs Removes shared log state and serializes assembly emission with [ResourceLock].
test/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompatibility.Tests/Microsoft.DotNet.ApiCompatibility.Tests.csproj Enables method-level MSTest parallelization for ApiCompatibility tests.

Review details

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

@Evangelink
Evangelink enabled auto-merge August 27, 2026 12:24
Wrap DefaultEnvironment so the bind-symbol test overrides only its target variable while preserving realistic behavior for every other IEnvironment member.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: fac66858-910b-458a-9c6d-6b6844f31c97
@Evangelink
Evangelink merged commit d2b9daa into main Aug 28, 2026
24 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/parallel-unit-test-pr branch August 28, 2026 02:07
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 29, 2026

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — ff1d4a48 Deployed Aug 28, 2026 by Evangelink via pre_activation #1403
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