Skip to content

Commit

Permalink
Port issues 1504 and 488 from 3.19
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Dec 22, 2024
1 parent 3887e1b commit 76c5f0e
Show file tree
Hide file tree
Showing 35 changed files with 1,200 additions and 1,163 deletions.
29 changes: 29 additions & 0 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
NuGet.config = NuGet.config
nunit.ico = nunit.ico
old-build.cake = old-build.cake
package-tests.cake = package-tests.cake
README.md = README.md
VERSIONING.md = VERSIONING.md
EndProjectSection
Expand Down Expand Up @@ -152,6 +153,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-net80", "src\NU
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-netcore31", "src\NUnitEngine\agents\nunit-agent-netcore31\nunit-agent-netcore31.csproj", "{446DAD12-87E5-47A4-B19E-D9F269ADEF72}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeExtensions", "src\TestData\FakeExtensions\FakeExtensions.csproj", "{1D84092C-32D7-4074-9FA6-5FA97335F173}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppContextTest", "src\TestData\AppContextTest\AppContextTest.csproj", "{E79A3CCD-07E2-4C50-B8BF-1C5844720725}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InvalidTestNames", "src\TestData\InvalidTestNames\InvalidTestNames.csproj", "{48DF1E40-93BA-436A-B460-5D1130316ADA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTest", "src\TestData\wpf-test\WpfTest.csproj", "{2F9D8932-2186-464F-BED6-7D7979C8FFA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -234,6 +243,22 @@ Global
{446DAD12-87E5-47A4-B19E-D9F269ADEF72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{446DAD12-87E5-47A4-B19E-D9F269ADEF72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{446DAD12-87E5-47A4-B19E-D9F269ADEF72}.Release|Any CPU.Build.0 = Release|Any CPU
{1D84092C-32D7-4074-9FA6-5FA97335F173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D84092C-32D7-4074-9FA6-5FA97335F173}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D84092C-32D7-4074-9FA6-5FA97335F173}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D84092C-32D7-4074-9FA6-5FA97335F173}.Release|Any CPU.Build.0 = Release|Any CPU
{E79A3CCD-07E2-4C50-B8BF-1C5844720725}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E79A3CCD-07E2-4C50-B8BF-1C5844720725}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E79A3CCD-07E2-4C50-B8BF-1C5844720725}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E79A3CCD-07E2-4C50-B8BF-1C5844720725}.Release|Any CPU.Build.0 = Release|Any CPU
{48DF1E40-93BA-436A-B460-5D1130316ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48DF1E40-93BA-436A-B460-5D1130316ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48DF1E40-93BA-436A-B460-5D1130316ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48DF1E40-93BA-436A-B460-5D1130316ADA}.Release|Any CPU.Build.0 = Release|Any CPU
{2F9D8932-2186-464F-BED6-7D7979C8FFA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F9D8932-2186-464F-BED6-7D7979C8FFA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F9D8932-2186-464F-BED6-7D7979C8FFA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F9D8932-2186-464F-BED6-7D7979C8FFA6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -271,6 +296,10 @@ Global
{0F76DA4A-58B9-4B45-BEC5-259105570D11} = {49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}
{CD357A8B-BE40-4F63-92DA-A71B94EE47E4} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
{446DAD12-87E5-47A4-B19E-D9F269ADEF72} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
{1D84092C-32D7-4074-9FA6-5FA97335F173} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{E79A3CCD-07E2-4C50-B8BF-1C5844720725} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{48DF1E40-93BA-436A-B460-5D1130316ADA} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{2F9D8932-2186-464F-BED6-7D7979C8FFA6} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
68 changes: 34 additions & 34 deletions package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -327,43 +327,43 @@ StandardRunnerTests.Add(new PackageTest(
// SPECIAL CASES
//////////////////////////////////////////////////////////////////////

// TODO: These are bugs fixed in V3 not yet ported
//StandardRunnerTests.Add(new PackageTest(
// 1, "InvalidTestNameTest_Net462",
// "Ensure we handle invalid test names correctly under .NET 4.6.2",
// "testdata/net462/InvalidTestNames.dll --trace:Debug",
// new ExpectedResult("Passed")
// {
// Assemblies = new ExpectedAssemblyResult[]
// {
// new ExpectedAssemblyResult("InvalidTestNames.dll", "net-4.6.2")
// }
// }));
StandardRunnerTests.Add(new PackageTest(
1, "InvalidTestNameTest_Net462",
"Ensure we handle invalid test names correctly under .NET 4.6.2",
"testdata/net462/InvalidTestNames.dll --trace:Debug",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "net-4.6.2")
}
}));

//AddToBothLists(new PackageTest(
// 1, "InvalidTestNameTest_Net60",
// "Ensure we handle invalid test names correctly under .NET 6.0",
// "testdata/net6.0/InvalidTestNames.dll --trace:Debug",
// new ExpectedResult("Passed")
// {
// Assemblies = new ExpectedAssemblyResult[]
// {
// new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-6.0")
// }
// }));
AddToBothLists(new PackageTest(
1, "InvalidTestNameTest_Net60",
"Ensure we handle invalid test names correctly under .NET 6.0",
"testdata/net6.0/InvalidTestNames.dll --trace:Debug",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-6.0")
}
}));

//AddToBothLists(new PackageTest(
// 1, "InvalidTestNameTest_Net80",
// "Ensure we handle invalid test names correctly under .NET 8.0",
// "testdata/net8.0/InvalidTestNames.dll --trace:Debug",
// new ExpectedResult("Passed")
// {
// Assemblies = new ExpectedAssemblyResult[]
// {
// new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-8.0")
// }
// }));
AddToBothLists(new PackageTest(
1, "InvalidTestNameTest_Net80",
"Ensure we handle invalid test names correctly under .NET 8.0",
"testdata/net8.0/InvalidTestNames.dll --trace:Debug",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
{
new ExpectedAssemblyResult("InvalidTestNames.dll", "netcore-8.0")
}
}));

// TODO: Bug fixed in V3 not yet ported
//StandardRunnerTests.Add(new PackageTest(
// 1, "AppContextBaseDirectory_NET80",
// "Test Setting the BaseDirectory to match test assembly location under .NET 8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public void CreateWriter()
_writer = new ExtendedTextWrapper(new StringWriter(_output));
}

[TestCase(char.MaxValue)]
public void TestNameContainsInvalidChar(char c)
{
Console.WriteLine($"Test for char {c}");
}

[TestCaseSource("SingleEventData")]
public void SingleEventsWriteExpectedOutput(string report, string labels, string expected)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface IDriverFactory
/// <param name="reference">An AssemblyName referring to the possible test framework.</param>
bool IsSupportedTestFramework(AssemblyName reference);

#if NETSTANDARD2_0
#if NETSTANDARD || NETCOREAPP
/// <summary>
/// Gets a driver for a given test assembly and a framework
/// which the assembly is already known to reference.
Expand Down
10 changes: 8 additions & 2 deletions src/NUnitEngine/nunit.engine.api/IExtensionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public interface IExtensionService
/// </summary>
IEnumerable<IExtensionNode> Extensions { get; }

/// <summary>
/// Find candidate extension assemblies starting from a given base directory,
/// and using the contained '.addins' files to direct the search.
/// </summary>
/// <param name="initialDirectory">Path to the initial directory.</param>
void FindExtensionAssemblies(string initialDirectory);

/// <summary>
/// Get an ExtensionPoint based on its unique identifying path.
/// </summary>
Expand All @@ -34,9 +41,8 @@ public interface IExtensionService
/// <summary>
/// Enable or disable an extension
/// </summary>
/// <param name="typeName"></param>
/// <param name="enabled"></param>
void EnableExtension(string typeName, bool enabled);

}
}

2 changes: 1 addition & 1 deletion src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class TestEngineActivator
private const string DefaultAssemblyName = "nunit.engine.dll";
internal const string DefaultTypeName = "NUnit.Engine.TestEngine";

#if NETSTANDARD2_0
#if NETSTANDARD || NETCOREAPP
/// <summary>
/// Create an instance of the test engine.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using System.IO;
using System.Runtime.Versioning;
using System.Reflection;
using NUnit.Engine.Extensibility;
using NUnit.Framework;
using NUnit.Framework.Internal;

namespace NUnit.Engine.Extensibility
namespace NUnit.Engine.Tests.Extensibility
{
// TODO: This should actually give us 3.5
[TestFixture("net462", FrameworkIdentifiers.NetFramework, "4.6.2")]
[TestFixture("netcoreapp3.1", FrameworkIdentifiers.NetCoreApp, "3.1")]
[TestFixture("net6.0", FrameworkIdentifiers.NetCoreApp, "6.0")]
public class ExtensionAssemblyTests
{
private string _assemblyPath;
private string _assemblyFileName;
private FrameworkName _expectedTargetRuntime;
private ExtensionAssembly _ea;
private static readonly Assembly THIS_ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly string THIS_ASSEMBLY_PATH = THIS_ASSEMBLY.Location;
private static readonly string THIS_ASSEMBLY_NAME = THIS_ASSEMBLY.GetName().Name;
private static readonly Version THIS_ASSEMBLY_VERSION = THIS_ASSEMBLY.GetName().Version;

public ExtensionAssemblyTests(string runtimeDir, string expectedRuntime, string expectedVersion)
{
_assemblyPath = TestData.MockAssemblyPath(runtimeDir);
_assemblyFileName = Path.GetFileNameWithoutExtension(_assemblyPath);
_expectedTargetRuntime = new FrameworkName(expectedRuntime, new Version(expectedVersion));
}
private ExtensionAssembly _ea;

[OneTimeSetUp]
public void CreateExtensionAssemblies()
{
_ea = new ExtensionAssembly(_assemblyPath, false);
_ea = new ExtensionAssembly(THIS_ASSEMBLY_PATH, false);
}

[Test]
public void AssemblyName()
{
Assert.That(_ea.AssemblyName, Is.EqualTo(_assemblyFileName));
Assert.That(_ea.AssemblyName, Is.EqualTo(THIS_ASSEMBLY_NAME));
}

[Test]
public void AssemblyVersion()
{
Assert.That(_ea.AssemblyVersion, Is.EqualTo(THIS_ASSEMBLY_VERSION));
}

#if NET462
[Test]
public void TargetFramework()
public void FrameworkName()
{
Assert.That(_ea.TargetRuntime, Is.EqualTo(_expectedTargetRuntime));
Assert.Multiple(() =>
{
Assert.That(_ea.FrameworkName.Identifier, Is.EqualTo(".NETFramework"));
Assert.That(_ea.FrameworkName.Version, Is.EqualTo(new Version(4,6,2)));
});
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static IExtensionAssembly MockExtension(string assemblyName = "Extension
sub.AssemblyName.Returns(assemblyName);
sub.AssemblyVersion.Returns(assemblyVersion ?? new Version(1, 0));
targetFramework = targetFramework ?? new Version(2, 0);
sub.TargetRuntime.Returns(new FrameworkName(FrameworkIdentifiers.NetFramework, targetFramework));
sub.FrameworkName.Returns(new FrameworkName(FrameworkIdentifiers.NetFramework, targetFramework));
sub.FromWildCard.Returns(fromWildcard);
return sub;
}
Expand Down

This file was deleted.

Loading

0 comments on commit 76c5f0e

Please sign in to comment.