Migrate test infrastructure from xUnit v2 to xUnit v3#52930
Migrate test infrastructure from xUnit v2 to xUnit v3#52930MichaelSimons wants to merge 36 commits intodotnet:mainfrom
Conversation
e96ea06 to
4682347
Compare
34b941b to
6769ca8
Compare
19ee58c to
d7555cd
Compare
a9a64c3 to
e9b7d9e
Compare
776bf9e to
f8ce147
Compare
201d8bb to
8840659
Compare
| <_CurrentAdditionalProperties>%(SDKCustomXUnitProject.AdditionalProperties)</_CurrentAdditionalProperties> | ||
| </PropertyGroup> | ||
| <MSBuild Projects="$(_CurrentSDKCustomXUnitProject)" Targets="PublishWithOutput" Properties="CustomAfterMicrosoftCommonTargets=$(_SDKCustomXUnitPublishTargetsPath);TargetFramework=$(_CurrentPublishTargetFramework);BuildTestPackages=false;$(_CurrentAdditionalProperties)"> | ||
| <!-- In CI, Arcade's centralized NuGet restore runs via NuGet.targets and does not |
There was a problem hiding this comment.
Can this be addressed in Arcade instead?
BTW, the test targets in Arcade SDK were created a long time ago, when the product test runners lacked necessary features. Can we now use dotnet test directly?
There was a problem hiding this comment.
Yes, I would like to do this in a follow-up PR.
…getRid) to test publish When cross-compiling for arm64 Helix queues (x64 build agent, TargetArchitecture=arm64), test projects were published without a RuntimeIdentifier. This caused the native AppHost to be built for the build machine (x64), which under Rosetta would invoke the arm64 dotnet from the test SDK payload, failing to load the x64 libhostpolicy.dylib. Apply the fix from #52930: add RuntimeIdentifier=$(TargetRid) to the test project publish and restore steps so the AppHost matches the arm64 Helix target architecture. Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/80a2fae2-c36c-46b1-9474-c8bb1e4f585c
On macOS arm64, unsigned binaries like createdump cannot execute due to Gatekeeper/SIP restrictions. This adds a Helix pre-command that finds any createdump binary in the correlation payload and ad-hoc signs it with codesign, allowing the .NET runtime to invoke createdump to collect crash dumps when a test process crashes. This mirrors the approach used in dotnet/runtime's sendtohelixhelp.proj. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The setup script (RunTestsOnHelix.sh) invokes numerous dotnet commands that could crash. Signing createdump first ensures dump collection is available for the entire Helix work item lifecycle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Ad-hoc codesign test AppHost executables on macOS Helix queues so createdump can attach via task_for_pid for crash dump collection. - Pass TargetRid to SDKCustomCreateXUnitWorkItemsWithTestExclusion for RID-based conditional logic. - Fix find -exec missing semicolon terminator in HelixPostCommands by escaping as %3B so MSBuild does not consume it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # test/Microsoft.NET.TestFramework/Attributes/PlatformSpecificFact.cs # test/Microsoft.NET.TestFramework/Attributes/PlatformSpecificTheory.cs # test/UnitTests.proj
The find -exec \; terminator was broken by a double-escaping issue: MSBuild resolved %3B to a literal semicolon, but the Helix SDK then split HelixPostCommands on that same semicolon, leaving find without its required terminator. Switch to find -print0 | xargs -0 which avoids the semicolon entirely. Verified locally that it copies .dmp files when present and exits cleanly when none are found. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The createdump binary from NuGet packages loses its code signature on extraction. Re-sign it on macOS Helix with the same entitlements used by dotnet/runtime (cs.debugger, allow-dyld-environment-variables, disable-library-validation) so it can call task_for_pid for crash dumps. Sign test AppHost executables with get-task-allow so createdump can attach to them as the target process. Two separate plist files are shipped via the Helix correlation payload: - helix-createdump-entitlements.plist for createdump (matches runtime) - helix-debug-entitlements.plist for test exes (get-task-allow) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@dotnet/dotnet-analyzers - After upgrading the NetAnalyzers to XUnit V3, I am seeing fairly consistent failures in the NetAnalyzers legs. Could you take a look at the crash dump. The following is a /ci-crash-dump analysis from Copilot. TIA. NetAnalyzers SIGSEGV Crash on macOS ARM64Summary
What's happeningThe crash occurs on Thread 23 inside the xUnit v3 test runner pipeline while executing The main thread (Thread 0) is blocked in Helix work item test filterThe The console log shows "No test matches the given testcase filter" but this message appeared after the process crash — the long-running test warnings confirm the tests were discovered and actively running before the SIGSEGV. The "no match" message is likely a non-issue (class-level filter that didn't match additional tests beyond what was already running). Contributing factors
Environment
ArtifactsCrashed thread stack (abbreviated)
|
|
Current status
|
The .NET runtime already ad-hoc signs createdump with the required entitlements at build time (src/coreclr/debug/createdump/CMakeLists.txt). The SDK's Helix pre-command was re-applying identical entitlements from a duplicate plist file, which is unnecessary. - Remove find/codesign pre-command for createdump from UnitTests.proj - Remove helix-createdump-entitlements.plist from Helix payload - Delete build/helix-createdump-entitlements.plist The helix-debug-entitlements.plist (get-task-allow for test executables) is retained since test EXEs are built by the SDK, not the runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@jeffhandley - I was given your name to help investigate a crash in the NetAnalyzer tests after upgrading to xunit v3 -- see #52930 (comment) for details. TIA. |
|
The only thing I can see that is really special with the specific class that's failing for NetAnalyzers tests is that it setup the tests with |
Related to #52914.
Switch all ~55 test projects from xUnit v2 (2.9.3) to xUnit v3 (3.2.2) using the arcade SDK's built-in XUnitV3.targets support. MTP enablement is deferred to a follow-up (#52914).
Key changes
TestRunnerName=XUnitV3andOutputType=Exeintest/Directory.Build.targetsxunit→xunit.v3,XUnitExtensions→XUnitV3Extensions,Verify.Xunit→Verify.XunitV3, TemplateEngine test packages to XunitV3 variantsProgram.csentry point (xUnit v3 generates its own)CallerFilePath/CallerLineNumberto custom Fact/Theory attributes (xUnit3003)chmod +xfor POSIX Helix work items (AppHost loses execute bit in zip)RuntimeIdentifierthrough test publish for cross-arch Helix queues