Skip to content

Commit

Permalink
Use xunit.console.exe for .NET Framework testing instead of `dotnet…
Browse files Browse the repository at this point in the history
… test`
  • Loading branch information
bradwilson committed Nov 15, 2023
1 parent 1057f30 commit 06d308b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- Universal properties and items -->

<PropertyGroup>
<AnnotatedReferenceAssemblyVersion>6.0.11</AnnotatedReferenceAssemblyVersion>
<AnnotatedReferenceAssemblyVersion>6.0.25</AnnotatedReferenceAssemblyVersion>
<ContinuousIntegrationBuild Condition=" '$(GITHUB_ACTIONS)' == 'true' ">true</ContinuousIntegrationBuild>
<DebugType Condition=" '$(TargetFrameworkIdentifier)' != '.NETCoreApp' ">full</DebugType>
<DebugType Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' ">embedded</DebugType>
Expand All @@ -25,7 +25,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="[4.0.1]" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
18 changes: 9 additions & 9 deletions src/xunit.analyzers.tests/Utility/CodeAnalyzerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
)
);

Expand All @@ -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")
)
);

Expand All @@ -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")
)
);

Expand All @@ -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")
)
);
}
Expand Down
21 changes: 9 additions & 12 deletions src/xunit.analyzers.tests/xunit.analyzers.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,22 @@
<PackageDownload Include="System.Collections.Immutable" Version="[1.6.0]" Condition=" '$(TargetFramework)' == 'net472' " />
<PackageDownload Include="System.Text.Json" Version="[6.0.0]" />
<PackageDownload Include="System.Threading.Tasks.Extensions" Version="[4.5.4]" />
<PackageDownload Include="xunit.assert" Version="[2.6.2-pre.12]" />
<PackageDownload Include="xunit.runner.utility" Version="[2.6.2-pre.12]" />
<PackageDownload Include="xunit.v3.assert" Version="[0.1.1-pre.317]" />
<PackageDownload Include="xunit.v3.common" Version="[0.1.1-pre.317]" />
<PackageDownload Include="xunit.v3.extensibility.core" Version="[0.1.1-pre.317]" />
<PackageDownload Include="xunit.v3.runner.utility" Version="[0.1.1-pre.317]" />
<PackageDownload Include="xunit.assert" Version="[2.6.2-pre.14]" />
<PackageDownload Include="xunit.runner.utility" Version="[2.6.2-pre.14]" />
<PackageDownload Include="xunit.v3.assert" Version="[0.1.1-pre.322]" />
<PackageDownload Include="xunit.v3.common" Version="[0.1.1-pre.322]" />
<PackageDownload Include="xunit.v3.extensibility.core" Version="[0.1.1-pre.322]" />
<PackageDownload Include="xunit.v3.runner.utility" Version="[0.1.1-pre.322]" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="xunit.assert.source" Version="2.6.2-pre.12" />
<PackageReference Include="xunit.core" Version="2.6.2-pre.12" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4-pre.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.assert.source" Version="2.6.2-pre.14" />
<PackageReference Include="xunit.core" Version="2.6.2-pre.14" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4-pre.10" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/xunit.analyzers.tests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://xUnit.net/schema/current/xunit.runner.schema.json",
"diagnosticMessages": true,
"maxParallelThreads": -1,
"shadowCopy": false
}
4 changes: 4 additions & 0 deletions tools/builder/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageDownload Include="xunit.v3.runner.console" Version="[0.1.1-pre.322]" />
</ItemGroup>

<ItemGroup>
<!-- We may not be able to upgrade Bullseye easily because we are leveraging internal APIs -->
<PackageReference Include="Bullseye" Version="3.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion tools/builder/common
Submodule common updated 1 files
+29 −0 models/BuildContext.cs
20 changes: 13 additions & 7 deletions tools/builder/targets/TestFx.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Threading.Tasks;
using SimpleExec;
using Xunit.BuildTools.Models;

namespace Xunit.BuildTools.Targets;
Expand All @@ -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"
);
}
}

0 comments on commit 06d308b

Please sign in to comment.