Skip to content

Fix racy mvid tests.#125537

Open
mrvoorhe wants to merge 1 commit intodotnet:mainfrom
Unity-Technologies:linker-fix-racey-mvid-tests
Open

Fix racy mvid tests.#125537
mrvoorhe wants to merge 1 commit intodotnet:mainfrom
Unity-Technologies:linker-fix-racey-mvid-tests

Conversation

@mrvoorhe
Copy link
Contributor

DeterministicMvidWorks, NewMvidWorks, and RetainMvid were running as part of All.CommandLineTests and as part of their own IndividualTests.

The individual test is going to use the same sandbox location as the All.CommandLineTests run uses.

This means that the two tests can conflict. Which I suspect explains why our CI randomly hit the error below.

Given that trimming these tests twice is wasteful. Let's update the individual test to run Check, giving the individual test the same coverage as when the test was running in All.CommandsLineTests. Then lets move the tests into an Individual folder so that they are not picked up by All.CommandsLineTests. Other tests in IndividualTests are following this pattern.

1) Failed : Mono.Linker.Tests.TestCases.All.CommandLine.Mvid.DeterministicMvidWorks
[19:40:23.176 Information] System.UnauthorizedAccessException : Access to the path 'test.exe' is denied.
   at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   at Mono.Linker.Tests.Extensions.NPath.Delete(DeleteMode deleteMode) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 580
   at Mono.Linker.Tests.Extensions.Extensions.Delete(IEnumerable`1 self) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 889
   at Mono.Linker.Tests.Extensions.NPath.DeleteContents() in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 614
   at Mono.Linker.Tests.TestCasesRunner.TestCaseSandbox..ctor(TestCase testCase, NPath rootTemporaryDirectory, String namePrefix) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestCaseSandbox.cs:line 45
   at Mono.Linker.Tests.TestCasesRunner.TestRunner.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestRunner.cs:line 35
   at Mono.Linker.Tests.TestCases.All.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 304
   at Mono.Linker.Tests.TestCases.All.CommandLineTests(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 64
   at InvokeStub_All.CommandLineTests(Object, Span`1)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2) Failed : Mono.Linker.Tests.TestCases.All.CommandLine.Mvid.NewMvidWorks
System.UnauthorizedAccessException : Access to the path 'test.exe' is denied.
   at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   at Mono.Linker.Tests.Extensions.NPath.Delete(DeleteMode deleteMode) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 580
   at Mono.Linker.Tests.Extensions.Extensions.Delete(IEnumerable`1 self) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 889
   at Mono.Linker.Tests.Extensions.NPath.DeleteContents() in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 614
   at Mono.Linker.Tests.TestCasesRunner.TestCaseSandbox..ctor(TestCase testCase, NPath rootTemporaryDirectory, String namePrefix) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestCaseSandbox.cs:line 45
   at Mono.Linker.Tests.TestCasesRunner.TestRunner.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestRunner.cs:line 35
   at Mono.Linker.Tests.TestCases.All.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 304
   at Mono.Linker.Tests.TestCases.All.CommandLineTests(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 64
   at InvokeStub_All.CommandLineTests(Object, Span`1)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
3) Failed : Mono.Linker.Tests.TestCases.All.CommandLine.Mvid.RetainMvid
System.UnauthorizedAccessException : Access to the path 'test.exe' is denied.
   at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   at Mono.Linker.Tests.Extensions.NPath.Delete(DeleteMode dele
[19:40:23.177 Information] teMode) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 580
   at Mono.Linker.Tests.Extensions.Extensions.Delete(IEnumerable`1 self) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 889
   at Mono.Linker.Tests.Extensions.NPath.DeleteContents() in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 614
   at Mono.Linker.Tests.TestCasesRunner.TestCaseSandbox..ctor(TestCase testCase, NPath rootTemporaryDirectory, String namePrefix) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestCaseSandbox.cs:line 45
   at Mono.Linker.Tests.TestCasesRunner.TestRunner.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestRunner.cs:line 35
   at Mono.Linker.Tests.TestCases.All.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 304
   at Mono.Linker.Tests.TestCases.All.CommandLineTests(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 64
   at InvokeStub_All.CommandLineTests(Object, Span`1)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

`DeterministicMvidWorks`, `NewMvidWorks`, and `RetainMvid` were running as part of `All.CommandLineTests` and as part of their own `IndividualTests`.

The individual test is going to use the same sandbox location as the `All.CommandLineTests` run uses.

This means that the two tests can conflict.  Which I suspect explains why our CI randomly hit the error below.

Given that trimming these tests twice is wasteful.  Let's update the individual test to run `Check`, giving the individual test the same coverage as when the test was running in `All.CommandsLineTests`.  Then lets move the tests into an `Individual` folder so that they are not picked up by `All.CommandsLineTests`.  Other tests in `IndividualTests` are following this pattern.

```
1) Failed : Mono.Linker.Tests.TestCases.All.CommandLine.Mvid.DeterministicMvidWorks
[19:40:23.176 Information] System.UnauthorizedAccessException : Access to the path 'test.exe' is denied.
   at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   at Mono.Linker.Tests.Extensions.NPath.Delete(DeleteMode deleteMode) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 580
   at Mono.Linker.Tests.Extensions.Extensions.Delete(IEnumerable`1 self) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 889
   at Mono.Linker.Tests.Extensions.NPath.DeleteContents() in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 614
   at Mono.Linker.Tests.TestCasesRunner.TestCaseSandbox..ctor(TestCase testCase, NPath rootTemporaryDirectory, String namePrefix) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestCaseSandbox.cs:line 45
   at Mono.Linker.Tests.TestCasesRunner.TestRunner.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestRunner.cs:line 35
   at Mono.Linker.Tests.TestCases.All.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 304
   at Mono.Linker.Tests.TestCases.All.CommandLineTests(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 64
   at InvokeStub_All.CommandLineTests(Object, Span`1)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2) Failed : Mono.Linker.Tests.TestCases.All.CommandLine.Mvid.NewMvidWorks
System.UnauthorizedAccessException : Access to the path 'test.exe' is denied.
   at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   at Mono.Linker.Tests.Extensions.NPath.Delete(DeleteMode deleteMode) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 580
   at Mono.Linker.Tests.Extensions.Extensions.Delete(IEnumerable`1 self) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 889
   at Mono.Linker.Tests.Extensions.NPath.DeleteContents() in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 614
   at Mono.Linker.Tests.TestCasesRunner.TestCaseSandbox..ctor(TestCase testCase, NPath rootTemporaryDirectory, String namePrefix) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestCaseSandbox.cs:line 45
   at Mono.Linker.Tests.TestCasesRunner.TestRunner.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestRunner.cs:line 35
   at Mono.Linker.Tests.TestCases.All.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 304
   at Mono.Linker.Tests.TestCases.All.CommandLineTests(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 64
   at InvokeStub_All.CommandLineTests(Object, Span`1)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
3) Failed : Mono.Linker.Tests.TestCases.All.CommandLine.Mvid.RetainMvid
System.UnauthorizedAccessException : Access to the path 'test.exe' is denied.
   at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
   at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
   at Mono.Linker.Tests.Extensions.NPath.Delete(DeleteMode dele
[19:40:23.177 Information] teMode) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 580
   at Mono.Linker.Tests.Extensions.Extensions.Delete(IEnumerable`1 self) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 889
   at Mono.Linker.Tests.Extensions.NPath.DeleteContents() in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\Extensions\NiceIO.cs:line 614
   at Mono.Linker.Tests.TestCasesRunner.TestCaseSandbox..ctor(TestCase testCase, NPath rootTemporaryDirectory, String namePrefix) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestCaseSandbox.cs:line 45
   at Mono.Linker.Tests.TestCasesRunner.TestRunner.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Trimming.Tests.Shared\TestRunner.cs:line 35
   at Mono.Linker.Tests.TestCases.All.Run(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 304
   at Mono.Linker.Tests.TestCases.All.CommandLineTests(TestCase testCase) in C:\build\output\unity\il2cpp\external\runtime\src\tools\illink\test\Mono.Linker.Tests\TestCases\TestSuites.cs:line 64
   at InvokeStub_All.CommandLineTests(Object, Span`1)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
```
@mrvoorhe mrvoorhe requested a review from sbomer as a code owner March 13, 2026 20:55
Copilot AI review requested due to automatic review settings March 13, 2026 20:55
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Mar 13, 2026
@dotnet-policy-service dotnet-policy-service bot added linkable-framework Issues associated with delivering a linker friendly framework community-contribution Indicates that the PR has been added by a community member labels Mar 13, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Copy link
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 addresses intermittent CI failures caused by the same MVID-related test cases being executed in multiple test suites that share the same sandbox path, leading to file access conflicts on cleanup.

Changes:

  • Updates the NUnit IndividualTests for MVID cases to run ResultChecker (Check(result)) so they retain the same validation coverage they previously got when run via the “All” suites.
  • Moves the MVID test cases into an Individual namespace/location so they are no longer picked up by the All.CommandLineTests suite discovery.
  • Regenerates the ILLink Roslyn analyzer test-suite mapping so these cases run under CommandLine.Mvid.Individual instead of CommandLine.Mvid.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tools/illink/test/Mono.Linker.Tests/TestCases/IndividualTests.cs Adds Check(result) to the three MVID individual tests and introduces a helper Check method using ResultChecker.
src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/Mvid/Individual/DeterministicMvidWorks.cs Updates namespace to ...Mvid.Individual to match on-disk Individual placement and avoid suite discovery conflicts.
src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/Mvid/Individual/NewMvidWorks.cs Same namespace update to ...Mvid.Individual.
src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/Mvid/Individual/RetainMvid.cs Same namespace update to ...Mvid.Individual.
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/.../CommandLine.MvidTests.g.cs Removes the three MVID tests from the non-individual CommandLine.Mvid analyzer suite.
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/.../CommandLine.Mvid.IndividualTests.g.cs Adds a new analyzer suite mapping for CommandLine.Mvid.Individual containing the three MVID tests.

@sbomer sbomer enabled auto-merge (squash) March 13, 2026 21:22
Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers community-contribution Indicates that the PR has been added by a community member linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants