Merge pull request #38 from nunit/updt-recipe

Update recipe version
This commit is contained in:
CharliePoole 2024-07-15 20:40:53 -07:00 коммит произвёл Charlie Poole
Родитель 976acd892a 5a6334a8d4
Коммит 0c281c198f
6 изменённых файлов: 61 добавлений и 23 удалений

Просмотреть файл

@ -1,4 +1,4 @@
next-version: 3.7.0
next-version: 3.8.0
mode: ContinuousDelivery
legacy-semver-padding: 5
build-metadata-padding: 5

Просмотреть файл

@ -2,10 +2,9 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.17.0
#tool nuget:?package=NUnit.ConsoleRunner&version=3.18.0-dev00037
#tool nuget:?package=NUnit.ConsoleRunner.NetCore&version=3.18.0-dev00037
#tool nuget:?package=NUnit.Extension.NUnitProjectLoader&version=3.6.0
// Load the recipe
#load nuget:?package=NUnit.Cake.Recipe&version=1.0.0-dev00001
#load nuget:?package=NUnit.Cake.Recipe&version=1.0.1-dev00001
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../NUnit.Cake.Recipe/recipe/*.cake
@ -16,7 +15,7 @@ BuildSettings.Initialize(
"nunit-v2-result-writer",
solutionFile: "nunit-v2-result-writer.sln",
unitTestRunner: new NUnitLiteRunner(),
unitTests: "**/*.Tests.exe");
unitTests: "**/*.tests.exe");
const string NUNIT3_RESULT_FILE = "TestResult.xml";
const string NUNIT2_RESULT_FILE = "NUnit2TestResult.xml";
@ -33,7 +32,17 @@ PackageTest[] PackageTests = new PackageTest[]
} ),
new PackageTest(
1, "TwoAssemblies",
1, "SingleAssembly_NetCoreRunner",
"Run mock-assembly under NetCore runner",
$"net6.0/mock-assembly.dll --result={NUNIT3_RESULT_FILE} --result={NUNIT2_RESULT_FILE};format=nunit2",
new ExpectedResult("Failed")
{
Assemblies = new[] { new ExpectedAssemblyResult("mock-assembly.dll", "netcore-6.0") }
},
new IPackageTestRunner[] { (IPackageTestRunner)new NUnitNetCoreConsoleRunner("3.18.0-dev00037") } ),
new PackageTest(
1, "TwoAssembliesTogether",
"Run two copies of mock-assembly",
$"net462/mock-assembly.dll net6.0/mock-assembly.dll --result={NUNIT3_RESULT_FILE} --result={NUNIT2_RESULT_FILE};format=nunit2",
new ExpectedResult("Failed") {
@ -54,13 +63,16 @@ PackageTest[] PackageTests = new PackageTest[]
new ExpectedAssemblyResult("mock-assembly.dll", "netcore-6.0")
}
},
KnownExtensions.NUnitProjectLoader )
KnownExtensions.NUnitProjectLoader.SetVersion("3.8.0") )
};
//////////////////////////////////////////////////////////////////////
// NUGET PACKAGE
//////////////////////////////////////////////////////////////////////
private TestRunnerSource DEFAULT_TEST_RUNNER_SOURCE = new TestRunnerSource (
new NUnitConsoleRunner("3.17.0"), new NUnitConsoleRunner("3.15.5"), new NUnitConsoleRunner("3.18.0-dev00037") );
BuildSettings.Packages.Add(
new NuGetPackage(
"NUnit.Extension.NUnitV2ResultWriter",
@ -72,7 +84,7 @@ BuildSettings.Packages.Add(
HasDirectory("tools/net6.0").WithFile("nunit-v2-result-writer.dll"),
HasDirectory("tools/net6.0").WithFile("nunit.engine.api.dll") },
tests: PackageTests,
testRunnerSource: new TestRunnerSource(new NUnitConsoleRunner("3.17.0"), new NUnitConsoleRunner("3.15.5"), new NUnitConsoleRunner("3.18.0-dev00037"))
testRunnerSource: DEFAULT_TEST_RUNNER_SOURCE
));
//////////////////////////////////////////////////////////////////////
@ -89,7 +101,7 @@ BuildSettings.Packages.Add(
HasDirectory("tools/net6.0").WithFile("nunit-v2-result-writer.dll"),
HasDirectory("tools/net6.0").WithFile("nunit.engine.api.dll") },
tests: PackageTests,
testRunnerSource: new TestRunnerSource(new NUnitConsoleRunner("3.17.0"), new NUnitConsoleRunner("3.15.5"), new NUnitConsoleRunner("3.18.0-dev00037"))
testRunnerSource: DEFAULT_TEST_RUNNER_SOURCE
));
//////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -79,7 +79,9 @@ namespace NUnit.Engine.Addins
DateTime start = result.GetAttribute("start-time", DateTime.UtcNow);
_xmlWriter.WriteAttributeString("date", start.ToString("yyyy-MM-dd"));
_xmlWriter.WriteAttributeString("time", start.ToString("HH:mm:ss"));
WriteEnvironment(assemblies[0].SelectSingleNode("environment")?.GetAttribute("framework-version"));
WriteEnvironment(GetFrameworkVersion(assemblies));
WriteCultureInfo();
}
@ -93,6 +95,22 @@ namespace NUnit.Engine.Addins
_xmlWriter.WriteEndElement();
}
private string GetFrameworkVersion(XmlNodeList assemblies)
{
// The nunit2 format requires a framework-version attribute as part of the environment
// element. This was an error in the original V2 design, since the various assemblies
// do not necessarily use the same framework version. To provide some value, we examine
// all the assemblies and return the first non-empty value found.
foreach (XmlNode node in assemblies)
{
var version = node.SelectSingleNode("environment")?.GetAttribute("framework-version");
if (!string.IsNullOrEmpty(version))
return version;
}
return string.Empty;
}
private void WriteEnvironment(string frameworkVersion)
{
_xmlWriter.WriteStartElement("environment");

Просмотреть файл

@ -54,18 +54,6 @@ namespace TestCentric.Tests
public static int Failures = MockTestFixture.Failures;
public static int Categories = MockTestFixture.Categories;
public static string AssemblyPath;
static MockAssembly()
{
var assembly = typeof(MockAssembly).Assembly;
string codeBase = assembly.EscapedCodeBase;
AssemblyPath = codeBase.ToLower().StartsWith(Uri.UriSchemeFile)
? new Uri(codeBase).LocalPath
: assembly.Location;
}
}
[TestFixture(Description = "Fake Test Fixture")]

19
src/tests/Program.cs Normal file
Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
using System.Reflection;
using NUnitLite;
namespace NUnit.Engine.Tests
{
class Program
{
static int Main(string[] args)
{
#if NETFRAMEWORK
return new TextRunner(typeof(Program).Assembly).Execute(args);
#else
return new TextRunner(typeof(Program).GetTypeInfo().Assembly).Execute(args);
#endif
}
}
}

Просмотреть файл

@ -4,6 +4,7 @@
<!-- If adding/updating TargetFrameworks, also update build.cake -->
<!-- Even though we don't support running tests build for netcoreapp2.1 yet, we still build for it -->
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<Configurations>Debug;Release</Configurations>
<RootNamespace>NUnit.Engine.Tests</RootNamespace>
<AssemblyName>nunit-v2-result-writer.tests</AssemblyName>
@ -16,9 +17,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="nunit.engine.api" Version="3.11.1" />
<!-- This is the newest NUnit that support .NET Framework 2.0 -->
<!-- This is the newest NUnit that supports .NET Framework 2.0 -->
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnitLite" Version="3.11.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\extension\nunit-v2-result-writer.csproj" />