Skip to content

Re-enable dotnet test tests on macOS ARM64 (#49665)#54485

Open
Evangelink wants to merge 2 commits into
mainfrom
dev/amauryleve/fix-49665-dotnet-test-macos-arm64
Open

Re-enable dotnet test tests on macOS ARM64 (#49665)#54485
Evangelink wants to merge 2 commits into
mainfrom
dev/amauryleve/fix-49665-dotnet-test-macos-arm64

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Re-enables the remaining dotnet test tests that were skipped on OSX as part of #49665.

Context

The underlying infrastructure issue was that Helix was installing the x64 .NET runtime on arm64 macOS machines (and vice versa for cross-arch jobs), which caused dlopen failures like:

Failed to load .../shared/Microsoft.NETCore.App/9.0.0/libhostpolicy.dylib, error: dlopen(...): tried '...' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

when running multi-TFM dotnet test tests that target the previous .NET runtime via DotnetVersionHelper.GetPreviousDotnetVersion().

That infrastructure issue was addressed in eng/restore-toolset.sh by:

  • 6d4031f Fix arm64 macOS CI installing x64 runtimes under Rosetta 2 (detects Rosetta + reinstalls the SDK and removes the cached x64 runtimes)
  • bba0cc1 Use TARGET_ARCHITECTURE env var for cross-arch runtime installation

Changes

This PR re-enables the following tests (removes the [PlatformSpecificTheory(TestPlatforms.Any & ~TestPlatforms.OSX)] skip and the issue/error comment, swaps back to [Theory]):

  • GivenDotnetTestBuildsAndDiscoversTests.DiscoverProjectWithMSTestMetaPackageAndMultipleTFMsWithTests_ShouldReturnExitCodeSuccess
  • GivenDotnetTestBuildsAndRunsHelp.RunHelpOnMultipleTestProjects_ShouldReturnExitCodeSuccess
  • GivenDotnetTestBuildsAndRunsTests.RunningWithGlobalPropertyShouldProperlyPropagate
  • GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunMultipleProjectWithDifferentTFMs_ShouldReturnExitCodeGenericFailure
  • GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunProjectWithMultipleTFMs_ShouldReturnExitCodeGenericFailure
  • GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunProjectWithMultipleTFMs_ParallelizationTest_RunInParallelShouldFail
  • GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunProjectWithMSTestMetaPackageAndMultipleTFMs_ShouldReturnExitCodeGenericFailure

Also fixes a real bug in RunTestProjectSolutionWithRuntimeOption_ShouldReturnExitCodeSuccess: the test hardcoded "x64" as the runtime architecture, so on arm64 macOS it tried to load the x64 host (have 'arm64', need 'x86_64' in the error message). The test now derives the architecture from the current process the same way the neighbouring tests do.

Relevance of #49665

Still relevant: there are additional tests skipped across publish/watch/blazor/etc. areas that reference the same issue. This PR only addresses the dotnet test subset that was the primary scope of the issue. The remaining tests should be tackled separately so this leg can be verified independently on CI.

Validation

Local Windows build of dotnet.Tests.csproj succeeds with 0 warnings / 0 errors. The macOS ARM64 leg is not runnable locally, so CI is the real validation here.

The underlying infrastructure issue (Helix installing the x64 .NET runtime
on arm64 macOS machines, causing 'incompatible architecture' dlopen failures
when running multi-TFM tests against the previous .NET runtime) was fixed in
eng/restore-toolset.sh by commits 6d4031f (Rosetta 2 detection +
reinstall) and bba0cc1 (use TARGET_ARCHITECTURE for cross-arch installs).

This re-enables the remaining dotnet test tests that were skipped on OSX
because of that infrastructure issue:

  - GivenDotnetTestBuildsAndDiscoversTests.DiscoverProjectWithMSTestMetaPackageAndMultipleTFMsWithTests_ShouldReturnExitCodeSuccess
  - GivenDotnetTestBuildsAndRunsHelp.RunHelpOnMultipleTestProjects_ShouldReturnExitCodeSuccess
  - GivenDotnetTestBuildsAndRunsTests.RunningWithGlobalPropertyShouldProperlyPropagate
  - GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunMultipleProjectWithDifferentTFMs_ShouldReturnExitCodeGenericFailure
  - GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunProjectWithMultipleTFMs_ShouldReturnExitCodeGenericFailure
  - GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunProjectWithMultipleTFMs_ParallelizationTest_RunInParallelShouldFail
  - GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.RunProjectWithMSTestMetaPackageAndMultipleTFMs_ShouldReturnExitCodeGenericFailure

Also fixes RunTestProjectSolutionWithRuntimeOption_ShouldReturnExitCodeSuccess,
which hardcoded 'x64' as the runtime architecture. On arm64 macOS the x64
runtime is not installed, which produced the 'have arm64, need x86_64'
mismatch in the test logs. It now derives the runtime architecture from the
current process the same way the neighbouring tests do.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 28, 2026 10:08
@Evangelink Evangelink requested a review from a team as a code owner May 28, 2026 10:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 re-enables previously skipped dotnet test coverage on macOS by removing the OSX exclusion for affected tests, and fixes one runtime RID selection in a test to use the current process architecture.

Changes:

  • Replaces OSX-excluding PlatformSpecificTheory attributes with regular [Theory].
  • Removes obsolete #49665 failure comments from re-enabled tests.
  • Updates one --runtime test to derive the runtime architecture dynamically instead of hardcoding x64.
Show a summary per file
File Description
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestsWithDifferentOptions.cs Re-enables the runtime-option test on macOS and derives the RID architecture from the current process.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestsForMultipleTFMs.cs Re-enables several multi-TFM dotnet test scenarios on macOS.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs Re-enables the global-property propagation test on macOS.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsHelp.cs Re-enables multi-project help output coverage on macOS.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndDiscoversTests.cs Re-enables MSTest multi-TFM discovery coverage on macOS.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 0

@Evangelink Evangelink enabled auto-merge May 29, 2026 06:49
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.

2 participants