Skip to content

Move libraries tests to xunit3#125019

Draft
agocke wants to merge 61 commits intodotnet:mainfrom
agocke:xunit3
Draft

Move libraries tests to xunit3#125019
agocke wants to merge 61 commits intodotnet:mainfrom
agocke:xunit3

Conversation

@agocke
Copy link
Member

@agocke agocke commented Mar 1, 2026

No description provided.

agocke and others added 21 commits January 16, 2026 15:52
Updated Dependencies:
Microsoft.CodeAnalysis, Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeAnalysis.CSharp, Microsoft.Net.Compilers.Toolset (Version 5.5.0-2.26124.102 -> 5.5.0-2.26127.101)
Microsoft.CodeAnalysis.NetAnalyzers, Microsoft.DotNet.ApiCompat.Task, Microsoft.NET.Workload.Emscripten.Current.Manifest-11.0.100.Transport (Version 11.0.100-preview.3.26124.102 -> 11.0.100-preview.3.26127.101)
Microsoft.DotNet.Arcade.Sdk, Microsoft.DotNet.Build.Tasks.Archives, Microsoft.DotNet.Build.Tasks.Feed, Microsoft.DotNet.Build.Tasks.Installers, Microsoft.DotNet.Build.Tasks.Packaging, Microsoft.DotNet.Build.Tasks.TargetFramework, Microsoft.DotNet.Build.Tasks.Templating, Microsoft.DotNet.Build.Tasks.Workloads, Microsoft.DotNet.CodeAnalysis, Microsoft.DotNet.GenAPI, Microsoft.DotNet.GenFacades, Microsoft.DotNet.Helix.Sdk, Microsoft.DotNet.PackageTesting, Microsoft.DotNet.RemoteExecutor, Microsoft.DotNet.SharedFramework.Sdk, Microsoft.DotNet.XliffTasks, Microsoft.DotNet.XUnitExtensions (Version 11.0.0-beta.26124.102 -> 11.0.0-beta.26127.101)
Microsoft.DotNet.Cecil (Version 0.11.5-preview.26124.102 -> 0.11.5-preview.26127.101)
Microsoft.DotNet.XUnitAssert, Microsoft.DotNet.XUnitConsoleRunner (Version 2.9.3-beta.26124.102 -> 2.9.3-beta.26127.101)
Microsoft.NET.Sdk.IL, Microsoft.NETCore.App.Ref, Microsoft.NETCore.ILAsm, runtime.native.System.IO.Ports, System.Reflection.Metadata, System.Reflection.MetadataLoadContext, System.Text.Json (Version 11.0.0-preview.3.26124.102 -> 11.0.0-preview.3.26127.101)
NuGet.Frameworks, NuGet.Packaging, NuGet.ProjectModel, NuGet.Versioning (Version 7.5.0-rc.12502 -> 7.5.0-rc.12801)
System.CommandLine (Version 3.0.0-preview.3.26124.102 -> 3.0.0-preview.3.26127.101)
[[ commit created by automation ]]
The test infrastructure was still using the xunit v2 external console runner
(dotnet exec ... xunit.console.dll) after the switch to xunit v3. Tests now
produce native executables with an embedded in-process runner and should be
invoked directly.

Changes:
- RunScriptCommand runs ./AssemblyName (Unix) or AssemblyName.exe (Windows)
  instead of dotnet exec with the external xunit.console.dll
- Set DOTNET_ROOT to RUNTIME_PATH in RunnerTemplate.sh/.cmd so the test
  executable can locate the shared framework
- Update xunit argument syntax for v3: -noLogo, -noColor, -maxThreads,
  -reporter verbose, -trait- (replaces -notrait)
- Remove Microsoft.DotNet.XUnitConsoleRunner PackageReference for .NETCoreApp
- Skip CopyRunnerToOutputDirectory for .NETCoreApp (runner is embedded)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace all uses of SkipTestException (from Microsoft.DotNet.XUnitV3Extensions)
with SkipException.ForSkip() (from Xunit.Sdk) across 117 test files.

- 'throw new SkipTestException(msg)' → 'throw SkipException.ForSkip(msg)'
- 'catch (SkipTestException)' → 'catch (SkipException)'
- Added 'using Xunit.Sdk;' where needed
- Updated comments and nameof() references

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pUnless

Where the pattern is a simple 'if (cond) { throw SkipException.ForSkip(msg); }',
convert to 'Assert.SkipWhen(cond, msg)' or 'Assert.SkipUnless(cond, msg)' to
match the xunit v3 idiom used in src/installer host tests.

147 conversions across 75 files. Complex cases (catch blocks, multi-statement
ifs, ternary expressions) retain throw SkipException.ForSkip().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 1, 2026 01:22
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

agocke and others added 3 commits March 1, 2026 08:44
xunit v3 changed libraries tests from running via 'dotnet exec
xunit.console.dll' to running './AssemblyName' directly as an embedded
runner executable. When the test archive ZIP is extracted on Helix
machines, the execute permission is not preserved, causing all libraries
test work items to fail with exit code 126 (Permission denied).

Add chmod +x for the test executable in SetScriptCommands, matching the
same approach used by host tests in helixpublish.proj. The chmod runs
in the generated RunTests.sh before test execution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 1, 2026 20:45
Copilot AI review requested due to automatic review settings March 11, 2026 08:48
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

agocke and others added 2 commits March 11, 2026 02:22
…e using

- Set UseAppHost=false in xunit.props for all library tests (they use
  dotnet exec, not apphost). Fixes NETSDK1084 when cross-compiling with
  an android RID from a linux-x64 host using the unix TFM.
- Set UseAppHost=true for NativeAOT tests in tests.singlefile.targets
  (overrides xunit.props) because SelfContained=true requires it.
- Add TestRunnerName=XUnitV3 and OutputType=Exe to ILVerification.Tests
  csproj. Add using Xunit.Sdk for IXunitSerializable/IXunitSerializationInfo.
- Remove stale using Xunit.Abstractions from HttpClientHandlerTest.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set RootNamespace to prevent xunit v3 auto-generated SelfRegisteredExtensions
from creating namespaces that conflict with library type names:

- System.ServiceProcess.ServiceController.Tests → System.ServiceProcess.Tests
- Microsoft.Win32.Registry.Tests → Microsoft.Win32.RegistryTests
- System.Reflection.DispatchProxy.Tests → DispatchProxyTests
- System.IO.IsolatedStorage.Tests → System.IO.IsolatedStorage.Tests
- Microsoft.Extensions.Options.Tests → Microsoft.Extensions.Options.Tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 11, 2026 09:30
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

agocke and others added 2 commits March 11, 2026 03:45
- Move UseAppHost=false from xunit.props to xunit.targets so it overrides
  the xunit.v3.core.mtp-v1 package's unconditional UseAppHost=true (the
  package's buildTransitive props are imported after Directory.Build.props
  but before Directory.Build.targets)
- Add UseAppHost=false and _XunitValidateBuild override to root
  Directory.Build.targets for non-library test projects (ILCompiler,
  ILVerification, cdac) that use Arcade's XUnitV3 runner
- Fix ILCompiler test runner args: -notrait → --filter-not-trait (xunit v3
  MTP CLI syntax)
- Fix RandomizedTestOrderAssemblyInfo.cs: use Type-based constructor for
  TestCaseOrdererAttribute/TestCollectionOrdererAttribute (xunit v3 API)
- Add RootNamespace to WinHttpHandler test projects to avoid CS0435
  namespace conflict with auto-generated SelfRegisteredExtensions
- Auto-generate complete CompatibilitySuppressions.xml for DI
  Specification.Tests (covers all TFMs)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Update ILLink.Descriptor.xunit.xml for xunit v3 assembly names
  (xunit.assert → xunit.v3.assert, xunit.core → xunit.v3.mtp-v1, etc.)
- Skip UseAppHost=false override for mobile/WASM (TargetsMobile=true) to
  avoid NETSDK1067 with SelfContained=true
- Disable XunitRegisterBuiltInRunnerReporters on mobile/WASM to avoid
  CS0012 (netstandard reference missing for DefaultRunnerReporters.cs)
- Remove erroneous UseAppHost=true for NativeAOT in tests.singlefile.targets
  (the SDK infers UseAppHost correctly for NativeAOT; xunit v3 package's
  UseAppHost=true is kept for SelfContained builds)
- Fix WinHttpHandler RootNamespace to avoid intermediate namespace segment
  System.Net.Http.WinHttpHandler conflicting with the type
- Set XunitAutoGeneratedEntryPoint=false for FunctionalTests (they have
  their own Main method; the xunit v3 auto-generated entry point conflicts)
- Fix IAsyncLifetime implementations to use ValueTask (xunit v3 change):
  JSInteropTestBase, WebWorkerTestBase, TimerTests, YieldAwaitableTests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 11, 2026 11:41
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Mar 11, 2026
agocke and others added 2 commits March 11, 2026 05:30
- Remove TargetsMobile condition from UseAppHost=false override - mobile
  and WASM platforms don't have an apphost, so UseAppHost=true from the
  xunit v3 package causes NETSDK1084. The SDK already exempts mobile/WASM
  RIDs from the NETSDK1067 check via _RuntimeIdentifierUsesAppHost=false.
- Add UseAppHost=false and _RuntimeIdentifierUsesAppHost=false for
  NativeAOT tests - ILC generates native executables directly, no apphost
  needed. Without _RuntimeIdentifierUsesAppHost=false, the SDK would
  error with NETSDK1067 (SelfContained=true + UseAppHost=false on desktop).
- Simplify ILLink.Descriptor.xunit.xml to preserve whole assemblies
  instead of referencing specific namespaces/types (IL2044 errors when
  namespaces don't exist in the actual assembly).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eAOT

- Set _RuntimeIdentifierUsesAppHost=false when SelfContained=true and
  UseAppHost=false to prevent NETSDK1067 on all self-contained test
  builds (mobile/WASM set SelfContained=true via tests.props).
- Set ValidateExecutableReferencesMatchSelfContained=false for NativeAOT
  test projects to prevent NETSDK1150. With xunit v3, test projects are
  OutputType=Exe, and the SDK checks that referenced Exe projects are
  also self-contained. Test helper Exe projects like TestExe are not
  self-contained, so the check must be disabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 11, 2026 13:16
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

…K1150

- NET481 tests: Run the test exe directly instead of via xunit.console.exe.
  xunit v3 .NETFramework test projects generate their own Main entry point
  and embed the in-process runner, just like .NETCoreApp projects.
- NativeAOT rd.xml: Update assembly name from 'Xunit.Assert' (v2) to
  'xunit.v3.assert' (v3) in System.Linq.Expressions default.rd.xml to
  fix 'Failed to load assembly' error during ILC compilation.
- ThreadPool namespace: Add RootNamespace to WindowsThreadPool.Tests to
  avoid CS0435 conflict between generated SelfRegisteredExtensions.cs
  namespace and the System.Threading.ThreadPool type.
- NETSDK1150: Apply ValidateExecutableReferencesMatchSelfContained=false
  to all self-contained test projects (not just NativeAOT) since xunit v3
  OutputType=Exe triggers SDK validation of referenced Exe projects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace unconditional xunit.v3.assert references with conditional
package references: Microsoft.DotNet.XUnitAssert for .NETCoreApp
targets and xunit.v3.assert for non-.NETCoreApp targets (e.g.,
.NETFramework, netstandard).

Bump Microsoft.DotNet.XUnitAssert to 3.2.2-beta.26168.106 which
includes xunit v3 Skip APIs (SkipWhen, SkipUnless, Skip).

Updated files:
- eng/testing/xunit/xunit.props (central, imported by all test projects)
- TestUtilities.csproj (multi-targets .NETCoreApp + .NETFramework)
- TestUtilities.Unicode.csproj (.NETCoreApp only)
- DependencyInjection.Specification.Tests.csproj (multi-targets)
- eng/Version.Details.props + eng/Version.Details.xml (version bump)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 20, 2026 07:31
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Resolve conflicts:
- Version.Details.props/xml: Take upstream versions, keep xunit3 XUnitAssert v3.2.2
- xunit.props: Combine OutputType/UseAppHost (xunit3) with xUnit1051 suppression (upstream)
- DumpTestBase.cs: Keep Assert.SkipWhen (xunit3 API), adopt dumpType ?? DumpType fix
- DumpTests.csproj: Keep XUnitV3Extensions package reference
- ICollectionTest/TensorPrimitives/CharUnicodeInfoTests/TestUtils: Take upstream formatting

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 20, 2026 22:18
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

- JsonSourceGeneratorOutputTests: Remove Xunit.Abstractions using (moved to Xunit namespace in v3)
- ThreadPoolBoundHandle.PlatformNotSupported: Add partial modifier for Browser+MT coexistence
- PortableThreadPool.Unix: Exclude from Browser+MT builds (Browser.Threads.cs provides stubs)
- ILLink.Descriptor.xunit.xml: Add Microsoft.DotNet.XUnitAssert alongside xunit.v3.assert
- Linq.Expressions rd.xml: Same assembly name fix for NativeAOT
- BinaryFormattedObjectTests: Replace obsolete Assert.Equivalent with Assert.Equal+Order
- DumpTests csproj: Suppress CS0618 for obsolete ConditionalTheory(params string[])

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 21, 2026 03:26
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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

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

Labels

area-Meta linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants