From 06d308b3f417c3b5ea1596a0538155113baa57a0 Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Wed, 15 Nov 2023 13:53:47 -0800 Subject: [PATCH] Use `xunit.console.exe` for .NET Framework testing instead of `dotnet test` --- src/Directory.Build.props | 4 ++-- .../Utility/CodeAnalyzerHelper.cs | 18 ++++++++-------- .../xunit.analyzers.tests.csproj | 21 ++++++++----------- src/xunit.analyzers.tests/xunit.runner.json | 1 + tools/builder/build.csproj | 4 ++++ tools/builder/common | 2 +- tools/builder/targets/TestFx.cs | 20 +++++++++++------- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8e1b27f7..e8a0181c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -4,7 +4,7 @@ - 6.0.11 + 6.0.25 true full embedded @@ -25,7 +25,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/xunit.analyzers.tests/Utility/CodeAnalyzerHelper.cs b/src/xunit.analyzers.tests/Utility/CodeAnalyzerHelper.cs index e93ce024..c2985fb5 100644 --- a/src/xunit.analyzers.tests/Utility/CodeAnalyzerHelper.cs +++ b/src/xunit.analyzers.tests/Utility/CodeAnalyzerHelper.cs @@ -11,7 +11,7 @@ static class CodeAnalyzerHelper public static readonly ReferenceAssemblies CurrentXunitV3RunnerUtility; - // When changing any references here, make sure to update xunit.analzyers.tests.csproj. + // When changing any references here, make sure to update xunit.analyzers.tests.csproj. // We either need a direct reference (like xunit.core) or a package download (like everything else) // in order for this list to work most efficiently. static CodeAnalyzerHelper() @@ -27,8 +27,8 @@ static CodeAnalyzerHelper() new PackageIdentity("System.Collections.Immutable", "1.6.0"), new PackageIdentity("System.Threading.Tasks.Extensions", "4.5.4"), new PackageIdentity("xunit.abstractions", "2.0.3"), - new PackageIdentity("xunit.assert", "2.6.2-pre.12"), - new PackageIdentity("xunit.core", "2.6.2-pre.12") + new PackageIdentity("xunit.assert", "2.6.2-pre.14"), + new PackageIdentity("xunit.core", "2.6.2-pre.14") ) ); @@ -37,7 +37,7 @@ static CodeAnalyzerHelper() new PackageIdentity("System.Collections.Immutable", "1.6.0"), new PackageIdentity("System.Threading.Tasks.Extensions", "4.5.4"), new PackageIdentity("xunit.abstractions", "2.0.3"), - new PackageIdentity("xunit.runner.utility", "2.6.2-pre.12") + new PackageIdentity("xunit.runner.utility", "2.6.2-pre.14") ) ); @@ -46,9 +46,9 @@ static CodeAnalyzerHelper() new PackageIdentity("Microsoft.Bcl.AsyncInterfaces", "6.0.0"), new PackageIdentity("System.Threading.Tasks.Extensions", "4.5.4"), new PackageIdentity("System.Text.Json", "6.0.0"), - new PackageIdentity("xunit.v3.assert", "0.1.1-pre.317"), - new PackageIdentity("xunit.v3.common", "0.1.1-pre.317"), - new PackageIdentity("xunit.v3.extensibility.core", "0.1.1-pre.317") + new PackageIdentity("xunit.v3.assert", "0.1.1-pre.322"), + new PackageIdentity("xunit.v3.common", "0.1.1-pre.322"), + new PackageIdentity("xunit.v3.extensibility.core", "0.1.1-pre.322") ) ); @@ -57,8 +57,8 @@ static CodeAnalyzerHelper() new PackageIdentity("Microsoft.Bcl.AsyncInterfaces", "6.0.0"), new PackageIdentity("System.Threading.Tasks.Extensions", "4.5.4"), new PackageIdentity("System.Text.Json", "6.0.0"), - new PackageIdentity("xunit.v3.common", "0.1.1-pre.317"), - new PackageIdentity("xunit.v3.runner.utility", "0.1.1-pre.317") + new PackageIdentity("xunit.v3.common", "0.1.1-pre.322"), + new PackageIdentity("xunit.v3.runner.utility", "0.1.1-pre.322") ) ); } diff --git a/src/xunit.analyzers.tests/xunit.analyzers.tests.csproj b/src/xunit.analyzers.tests/xunit.analyzers.tests.csproj index f64b86ca..8b41fb4c 100644 --- a/src/xunit.analyzers.tests/xunit.analyzers.tests.csproj +++ b/src/xunit.analyzers.tests/xunit.analyzers.tests.csproj @@ -16,12 +16,12 @@ - - - - - - + + + + + + @@ -29,12 +29,9 @@ - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + + diff --git a/src/xunit.analyzers.tests/xunit.runner.json b/src/xunit.analyzers.tests/xunit.runner.json index 33d08cc8..7b91a367 100644 --- a/src/xunit.analyzers.tests/xunit.runner.json +++ b/src/xunit.analyzers.tests/xunit.runner.json @@ -1,5 +1,6 @@ { "$schema": "https://xUnit.net/schema/current/xunit.runner.schema.json", "diagnosticMessages": true, + "maxParallelThreads": -1, "shadowCopy": false } diff --git a/tools/builder/build.csproj b/tools/builder/build.csproj index 4a3aef1f..00a1b468 100644 --- a/tools/builder/build.csproj +++ b/tools/builder/build.csproj @@ -8,6 +8,10 @@ true + + + + diff --git a/tools/builder/common b/tools/builder/common index 46185ff6..0b441c32 160000 --- a/tools/builder/common +++ b/tools/builder/common @@ -1 +1 @@ -Subproject commit 46185ff648e231ae79df8df1cf9a8cdc3359c69c +Subproject commit 0b441c32eb7de05bbebdd7f80602ed9b2be04dd7 diff --git a/tools/builder/targets/TestFx.cs b/tools/builder/targets/TestFx.cs index 87ad1d05..8d682d8b 100644 --- a/tools/builder/targets/TestFx.cs +++ b/tools/builder/targets/TestFx.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Threading.Tasks; +using SimpleExec; using Xunit.BuildTools.Models; namespace Xunit.BuildTools.Targets; @@ -15,17 +16,22 @@ public static Task OnExecute(BuildContext context) { context.BuildStep("Running .NET Framework tests"); - if (context.NeedMono) - { - context.WriteLineColor(ConsoleColor.Yellow, "Skipping .NET Framework tests on non-Windows OSes."); - Console.WriteLine(); + var consoleRunner = Path.Combine(context.NuGetPackageCachePath, "xunit.v3.runner.console", "0.1.1-pre.322", "tools", "net472", "xunit.v3.runner.console.exe"); - return Task.CompletedTask; + if (!File.Exists(consoleRunner)) + { + context.WriteLineColor(ConsoleColor.Red, $"Cannot run .NET Framework tests because path '{consoleRunner}' does not exist"); + throw new ExitCodeException(-1); } var resultPath = Path.Combine(context.BaseFolder, "artifacts", "test"); - File.Delete(Path.Combine(resultPath, "netfx.trx")); + var trxFilePath = Path.Combine(resultPath, "netfx.trx"); + File.Delete(trxFilePath); - return context.Exec("dotnet", $"test src/xunit.analyzers.tests --framework net472 --configuration {context.ConfigurationText} --no-build --logger trx;LogFileName=netfx.trx --results-directory \"{resultPath}\" --verbosity {context.Verbosity}"); + return context.Exec( + consoleRunner, + $"xunit.analyzers.tests.dll -trx \"{trxFilePath}\"", + workingDirectory: $"src/xunit.analyzers.tests/bin/{context.ConfigurationText}/net472" + ); } }