Skip to content

Commit

Permalink
Eliminate .NET Standard 2.0 build of nunit.engine
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Oct 21, 2024
1 parent 4b99290 commit 63d671b
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 37 deletions.
8 changes: 8 additions & 0 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "zip", "zip", "{20005864-BE82-412D-99BF-288E2D8370E9}"
ProjectSection(SolutionItems) = preProject
zip\nunit.bundle.addins = zip\nunit.bundle.addins
zip\nunit.bundle.agent.addins = zip\nunit.bundle.agent.addins
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.engine.core.tests", "src\NUnitEngine\nunit.engine.core.tests\nunit.engine.core.tests.csproj", "{CACC0520-B452-4310-A33C-DC944129ACDD}"
Expand Down Expand Up @@ -153,6 +154,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8.0", "net8.0", "{303CF8
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mock-assembly-v2", "src\TestData\mock-assembly-v2\mock-assembly-v2.csproj", "{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FakeExtensions", "src\TestData\FakeExtensions\FakeExtensions.csproj", "{D6C217E0-BFB7-4C80-8D50-C969F46EBC59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -235,6 +238,10 @@ Global
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78}.Release|Any CPU.Build.0 = Release|Any CPU
{D6C217E0-BFB7-4C80-8D50-C969F46EBC59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6C217E0-BFB7-4C80-8D50-C969F46EBC59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6C217E0-BFB7-4C80-8D50-C969F46EBC59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6C217E0-BFB7-4C80-8D50-C969F46EBC59}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -271,6 +278,7 @@ Global
{E43A3E4B-B050-471B-B43C-0DF60FD44376} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
{303CF83E-2A87-4882-8CAC-3EB59AAD81FC} = {F3E87D0F-6F06-4C0B-AE06-42C0834C3C6E}
{AD40CA55-35CC-41CA-85F5-8FDA4ECAFF78} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
{D6C217E0-BFB7-4C80-8D50-C969F46EBC59} = {2ECE1CFB-9436-4149-B7E4-1FB1786FDE9F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
13 changes: 8 additions & 5 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
source: BuildSettings.ZipImageDirectory,
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt", "CHANGES.txt"),
HasDirectory("bin/net462").WithFiles("nunit3-console.exe", "nunit3-console.exe.config", "nunit3-console.pdb").AndFiles(ENGINE_FILES).AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/netstandard2.0").WithFiles(ENGINE_FILES).AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/net462").WithFiles("nunit3-console.exe", "nunit3-console.exe.config",
"nunit3-console.pdb").AndFiles(ENGINE_FILES).AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/net462/addins").WithFiles(
"nunit.core.dll", "nunit.core.interfaces.dll", "nunit.engine.api.dll",
"nunit.v2.driver.dll", "nunit-project-loader.dll", "nunit-v2-result-writer.dll",
"teamcity-event-listener.dll", "vs-project-loader.dll"),
HasDirectory("bin/netstandard2.0").WithFiles(ENGINE_CORE_FILES).AndFiles(ENGINE_CORE_PDB_FILES),
HasDirectory("bin/netcoreapp3.1").WithFiles(ENGINE_CORE_FILES).AndFiles(ENGINE_CORE_PDB_FILES),
HasDirectory("bin/agents/net462").WithFiles(AGENT_FILES).AndFiles(AGENT_PDB_FILES),
HasDirectory("bin/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("bin/agents/net7.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("bin/agents/net8.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE)
HasDirectory("bin/agents/net8.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE),
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.ZipTestDirectory
+ $"NUnit.Console.{BuildSettings.PackageVersion}/bin/net462/nunit3-console.exe"),
Expand All @@ -146,10 +151,8 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt"),
HasDirectory("lib/net462").WithFiles(ENGINE_FILES),
HasDirectory("lib/netstandard2.0").WithFiles(ENGINE_FILES),
HasDirectory("lib/net8.0").WithFiles(ENGINE_FILES).AndFile("Microsoft.Extensions.DependencyModel.dll"),
HasDirectory("contentFiles/any/lib/net462").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/lib/netstandard2.0").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/lib/net8.0").WithFile("nunit.engine.nuget.addins"),
HasDirectory("contentFiles/any/agents/net462").WithFiles(AGENT_FILES).AndFile("nunit.agent.addins")
},
Expand Down
9 changes: 0 additions & 9 deletions nuget/engine/nunit.engine.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@
<file src="../../nuget/engine/nunit.agent.addins" target="contentFiles/any/agents/net40"/>
<file src="../../nuget/engine/nunit.agent.addins" target="contentFiles/any/agents/netcoreapp3.1"/>

<file src="netstandard2.0/nunit.engine.dll" target="lib/netstandard2.0" />
<file src="netstandard2.0/nunit.engine.pdb" target="lib/netstandard2.0" />
<file src="netstandard2.0/nunit.engine.core.dll" target="lib/netstandard2.0" />
<file src="netstandard2.0/nunit.engine.core.pdb" target="lib/netstandard2.0" />
<file src="netstandard2.0/nunit.engine.api.dll" target="lib/netstandard2.0" />
<file src="netstandard2.0/nunit.engine.api.pdb" target="lib/netstandard2.0" />
<file src="netstandard2.0/testcentric.engine.metadata.dll" target="lib/netstandard2.0" />
<file src="../../nuget/engine/nunit.engine.nuget.addins" target="contentFiles/any/lib/netstandard2.0"/>

<file src="net8.0/nunit.engine.dll" target="lib/net8.0" />
<file src="net8.0/nunit.engine.pdb" target="lib/net8.0" />
<file src="net8.0/nunit.engine.core.dll" target="lib/net8.0" />
Expand Down
4 changes: 2 additions & 2 deletions package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ StandardRunnerTests.Add(new PackageTest(
StandardRunnerTests.Add(new PackageTest(
1, "V2FrameworkDriverTest",
"Run mock-assembly-v2 using the V2 Driver in process",
"v2-tests/net462/mock-assembly-v2.dll --inprocess",
"v2-tests/net462/mock-assembly-v2.dll",
new ExpectedResult("Failed")
{
Total = 28,
Expand All @@ -280,7 +280,7 @@ StandardRunnerTests.Add(new PackageTest(
StandardRunnerTests.Add(new PackageTest(
1, "V2FrameworkDriverTest",
"Run mock-assembly-v2 using the V2 Driver out of process",
"v2-tests/net462/mock-assembly-v2.dll --trace:Debug",
"v2-tests/net462/mock-assembly-v2.dll --list-extensions",
new ExpectedResult("Failed")
{
Total = 28,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.ConsoleRunner.Tests</RootNamespace>
<TargetFrameworks>net462;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<StartupObject>NUnit.Engine.Tests.Program</StartupObject>
<NoWarn>1685</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using NUnit.Engine.Internal;
using NSubstitute;
using NUnit.Engine.Internal.FileSystemAccess;
using System.Diagnostics;

namespace NUnit.Engine.Services.Tests
{
Expand Down Expand Up @@ -57,9 +58,12 @@ public void CreateExtensionManager()
// Find actual extension points.
_extensionManager.FindExtensionPoints(typeof(CoreEngine).Assembly);
_extensionManager.FindExtensionPoints(typeof(ITestEngine).Assembly);

// Find dummy extensions in this test assembly.
_extensionManager.FindExtensionsInAssembly(new ExtensionAssembly(GetType().Assembly.Location, false));
// Find extensions.
#if NETCOREAPP
_extensionManager.FindExtensionsInAssembly(FakeExtensions("netstandard2.0"));
#else
_extensionManager.FindExtensionsInAssembly(FakeExtensions("net462"));
#endif
}

[Test]
Expand Down Expand Up @@ -161,21 +165,39 @@ public void SkipsGracefullyLoadingOtherFrameworkExtensionAssembly()
Assert.That(() => service.FindExtensionsInAssembly(extensionAssembly), Throws.Nothing);
}

[TestCaseSource(nameof(ValidCombos))]
#if NETCOREAPP
[TestCase("netstandard2.0", ExpectedResult = true)]
[TestCase("net462", ExpectedResult = false)]
//[TestCase("net20", ExpectedResult = false)]
#elif NET40_OR_GREATER
[TestCase("netstandard2.0", ExpectedResult = false)]
[TestCase("net462", ExpectedResult = true)]
//[TestCase("net20", ExpectedResult = true)]
#else
[TestCase("netstandard2.0", ExpectedResult = false)]
[TestCase("net462", ExpectedResult = false)]
//[TestCase("net20", ExpectedResult = true)]
#endif
public bool LoadTargetFramework(string tfm)
{
return _extensionManager.CanLoadTargetFramework(THIS_ASSEMBLY, FakeExtensions(tfm));
}

//[TestCaseSource(nameof(ValidCombos))]
public void ValidTargetFrameworkCombinations(FrameworkCombo combo)
{
Assert.That(() => _extensionManager.CanLoadTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly),
Is.True);
}

[TestCaseSource(nameof(InvalidTargetFrameworkCombos))]
//[TestCaseSource(nameof(InvalidTargetFrameworkCombos))]
public void InvalidTargetFrameworkCombinations(FrameworkCombo combo)
{
Assert.That(() => _extensionManager.CanLoadTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly),
Is.False);
}

[TestCaseSource(nameof(InvalidRunnerCombos))]
//[TestCaseSource(nameof(InvalidRunnerCombos))]
public void InvalidRunnerTargetFrameworkCombinations(FrameworkCombo combo)
{
var ex = Assert.Catch(() => _extensionManager.CanLoadTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly));
Expand Down Expand Up @@ -275,5 +297,23 @@ private static string GetSiblingDirectory(string dir)
var file = new FileInfo(typeof(ExtensionManagerTests).Assembly.Location);
return Path.Combine(file.Directory.Parent.FullName, dir);
}

private static readonly Assembly THIS_ASSEMBLY = typeof(ExtensionManagerTests).Assembly;
private static readonly string THIS_ASSEMBLY_DIRECTORY = Path.GetDirectoryName(THIS_ASSEMBLY.Location);
private const string FAKE_EXTENSIONS_FILENAME = "FakeExtensions.dll";
private static readonly string FAKE_EXTENSIONS_PARENT_DIRECTORY =
Path.Combine(new DirectoryInfo(THIS_ASSEMBLY_DIRECTORY).Parent.FullName, "fakes");

/// <summary>
/// Returns an ExtensionAssembly referring to a particular build of the fake test extensions
/// assembly based on the argument provided.
/// </summary>
/// <param name="tfm">A test framework moniker. Must be one for which the fake extensions are built.</param>
/// <returns></returns>
private static ExtensionAssembly FakeExtensions(string tfm)
{
return new ExtensionAssembly(
Path.Combine(FAKE_EXTENSIONS_PARENT_DIRECTORY, Path.Combine(tfm, FAKE_EXTENSIONS_FILENAME)), false);
}
}
}
14 changes: 2 additions & 12 deletions src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.Engine.Tests</RootNamespace>
<TargetFrameworks>net462;netcoreapp3.1;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
Expand All @@ -17,13 +17,7 @@
<Description>Tests of nunit.engine assembly</Description>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnitLite" Version="3.14.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='netcoreapp3.1'">
<ItemGroup>
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnitLite" Version="4.2.2" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
Expand All @@ -35,10 +29,6 @@
<Reference Include="System.Web" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\TestData\mock-assembly\mock-assembly.csproj" />
<ProjectReference Include="..\nunit.engine.api\nunit.engine.api.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitEngine/nunit.engine/nunit.engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.Engine</RootNamespace>
<TargetFrameworks>net462;netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<DebugType>portable</DebugType>
Expand Down
15 changes: 15 additions & 0 deletions src/TestData/FakeExtensions/FakeExtensions.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<RootNamespace>TestCentric.Extensibility</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<OutputPath>..\..\..\bin\$(Configuration)\fakes</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\NUnitEngine\nunit.engine.api\nunit.engine.api.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/TestData/mock-assembly-v2/MockAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using NUnit.Framework;

namespace TestCentric.Tests
namespace NUnit.Tests
{
namespace Assemblies
{
Expand Down
5 changes: 5 additions & 0 deletions zip/nunit.bundle.agent.addins
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
../../addins/nunit.v2.driver.dll
../../addins/nunit-v2-result-writer.dll
../../addins/nunit-project-loader.dll
../../addins/vs-project-loader.dll
../../addins/teamcity-event-listener.dll

0 comments on commit 63d671b

Please sign in to comment.