Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update recipe to match project loader #1442

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -136,36 +136,36 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{C5B712
.config\dotnet-tools.json = .config\dotnet-tools.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{D6449B7A-20FF-467B-A65E-174DD6992AEB}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "recipe", "recipe", "{D6449B7A-20FF-467B-A65E-174DD6992AEB}"
ProjectSection(SolutionItems) = preProject
cake\banner.cake = cake\banner.cake
cake\build-settings.cake = cake\build-settings.cake
cake\builder.cake = cake\builder.cake
cake\chocolatey-package.cake = cake\chocolatey-package.cake
cake\command-line-options.cake = cake\command-line-options.cake
cake\constants.cake = cake\constants.cake
cake\dotnet.cake = cake\dotnet.cake
cake\extending.cake = cake\extending.cake
cake\headers.cake = cake\headers.cake
cake\help-messages.cake = cake\help-messages.cake
cake\known-extensions.cake = cake\known-extensions.cake
cake\nuget-package.cake = cake\nuget-package.cake
cake\package-checks.cake = cake\package-checks.cake
cake\package-definition.cake = cake\package-definition.cake
cake\package-reference.cake = cake\package-reference.cake
cake\package-test.cake = cake\package-test.cake
cake\publishing.cake = cake\publishing.cake
cake\setup.cake = cake\setup.cake
cake\task-builders.cake = cake\task-builders.cake
cake\task-definitions.cake = cake\task-definitions.cake
cake\test-reports.cake = cake\test-reports.cake
cake\test-results.cake = cake\test-results.cake
cake\test-runners.cake = cake\test-runners.cake
cake\tools.cake = cake\tools.cake
cake\unit-testing.cake = cake\unit-testing.cake
cake\utilities.cake = cake\utilities.cake
cake\versioning.cake = cake\versioning.cake
cake\zip-package.cake = cake\zip-package.cake
recipe\banner.cake = recipe\banner.cake
recipe\build-settings.cake = recipe\build-settings.cake
recipe\builder.cake = recipe\builder.cake
recipe\chocolatey-package.cake = recipe\chocolatey-package.cake
recipe\command-line-options.cake = recipe\command-line-options.cake
recipe\constants.cake = recipe\constants.cake
recipe\dotnet.cake = recipe\dotnet.cake
recipe\extending.cake = recipe\extending.cake
recipe\headers.cake = recipe\headers.cake
recipe\help-messages.cake = recipe\help-messages.cake
recipe\known-extensions.cake = recipe\known-extensions.cake
recipe\nuget-package.cake = recipe\nuget-package.cake
recipe\package-checks.cake = recipe\package-checks.cake
recipe\package-definition.cake = recipe\package-definition.cake
recipe\package-reference.cake = recipe\package-reference.cake
recipe\package-test.cake = recipe\package-test.cake
recipe\publishing.cake = recipe\publishing.cake
recipe\setup.cake = recipe\setup.cake
recipe\task-builders.cake = recipe\task-builders.cake
recipe\task-definitions.cake = recipe\task-definitions.cake
recipe\test-reports.cake = recipe\test-reports.cake
recipe\test-results.cake = recipe\test-results.cake
recipe\test-runners.cake = recipe\test-runners.cake
recipe\tools.cake = recipe\tools.cake
recipe\unit-testing.cake = recipe\unit-testing.cake
recipe\utilities.cake = recipe\utilities.cake
recipe\versioning.cake = recipe\versioning.cake
recipe\zip-package.cake = recipe\zip-package.cake
EndProjectSection
EndProject
Global
Expand Down
19 changes: 11 additions & 8 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load scripts
#load cake/*.cake
#load recipe/*.cake

// Initialize BuildSettings
BuildSettings.Initialize(
Expand Down Expand Up @@ -357,9 +357,9 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {

// Custom unit test runner to run console vs engine tests differently
// TODO: Use NUnitLite for all tests?
public class CustomTestRunner : UnitTestRunner
public class CustomTestRunner : TestRunner, IUnitTestRunner
{
public override int Run(FilePath testPath)
public int RunUnitTest(FilePath testPath)
{
// Run console tests under the just-built console
if(testPath.ToString().Contains("nunit3-console.tests.dll"))
Expand All @@ -370,21 +370,24 @@ public class CustomTestRunner : UnitTestRunner
}

// All other tests use NUnitLite
return new NUnitLiteRunner().Run(testPath);
return new NUnitLiteRunner().RunUnitTest(testPath);
}
}

// Use the console runner we just built to run package tests
public class ConsoleRunnerSelfTester : PackageTestRunner
public class ConsoleRunnerSelfTester : TestRunner, IPackageTestRunner
{
private string _executablePath;

public ConsoleRunnerSelfTester(string executablePath)
{
ExecutablePath = executablePath;
_executablePath = executablePath;
}

public override int Run(string arguments)
public int RunPackageTest(string arguments)
{
return base.Run(arguments);
Console.WriteLine("Running package test");
return base.RunTest(_executablePath, arguments);
}
}

Expand Down
34 changes: 0 additions & 34 deletions cake/package-test.cake

This file was deleted.

117 changes: 0 additions & 117 deletions cake/test-runners.cake

This file was deleted.

4 changes: 0 additions & 4 deletions cake/tools.cake

This file was deleted.

2 changes: 1 addition & 1 deletion nuget/runners/nunit.console-runner.netcore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<file src="net6.0/nunit3-console.exe" target="tools/net6.0/" />
<file src="net6.0/nunit3-console.pdb" target="tools/net6.0/" />
<file src="net6.0/nunit3-console.dll" target="tools/net6.0/" />
<file src="net6.0/nunit3-console.dll.config" target="tools/met6.0" />
<file src="net6.0/nunit3-console.dll.config" target="tools/net6.0" />
<file src="net6.0/nunit3-console.deps.json" target="tools/net6.0" />
<file src="net6.0/nunit3-console.runtimeconfig.json" target="tools/net6.0" />
<file src="net6.0/nunit.engine.core.dll" target="tools/net6.0" />
Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions cake/build-settings.cake → recipe/build-settings.cake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class BuildSettings
Verbosity msbuildVerbosity = Verbosity.Minimal,

string unitTests = null, // Defaults to "**/*.tests.dll|**/*.tests.exe" (case insensitive)
UnitTestRunner unitTestRunner = null, // If not set, NUnitLite is used
IUnitTestRunner unitTestRunner = null, // If not set, NUnitLite is used
string unitTestArguments = null
)
{
Expand Down Expand Up @@ -85,11 +85,11 @@ public static class BuildSettings
// the solution found in the root directory provided there is only one.
private static string DeduceSolutionFile()
{
if (System.IO.File.Exists(Title + ".sln"))
if (SIO.File.Exists(Title + ".sln"))
return Title + ".sln";

var files = System.IO.Directory.GetFiles(ProjectDirectory, "*.sln");
if (files.Length == 1 && System.IO.File.Exists(files[0]))
var files = SIO.Directory.GetFiles(ProjectDirectory, "*.sln");
if (files.Length == 1 && SIO.File.Exists(files[0]))
return files[0];

return null;
Expand Down Expand Up @@ -203,7 +203,7 @@ public static class BuildSettings

//Testing
public static string UnitTests { get; set; }
public static UnitTestRunner UnitTestRunner { get; private set; }
public static IUnitTestRunner UnitTestRunner { get; private set; }
public static string UnitTestArguments { get; private set; }

// Packaging
Expand Down Expand Up @@ -310,6 +310,7 @@ public static class BuildSettings
Console.WriteLine("UnitTestRunner: " + UnitTestRunner?.GetType().Name ?? "<NUnitLiteRunner>");

Console.WriteLine("\nPACKAGING");
Console.WriteLine("PackageTestLevel: " + PackageTestLevel);
Console.WriteLine("MyGetPushUrl: " + MyGetPushUrl);
Console.WriteLine("NuGetPushUrl: " + NuGetPushUrl);
Console.WriteLine("ChocolateyPushUrl: " + ChocolateyPushUrl);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ public class ChocolateyPackage : PackageDefinition
public ChocolateyPackage(
string id,
string source,
PackageTestRunner testRunner = null,
IPackageTestRunner testRunner = null,
TestRunnerSource testRunnerSource = null,
PackageCheck[] checks = null,
IEnumerable<PackageTest> tests = null)
: base(
PackageType.Chocolatey,
id,
source,
testRunner: testRunner,
testRunnerSource: testRunnerSource,
checks: checks,
tests: tests)
{
Expand All @@ -21,7 +23,7 @@ public class ChocolateyPackage : PackageDefinition
// The file name of this package, including extension
public override string PackageFileName => $"{PackageId}.{PackageVersion}.nupkg";
// The file name of any symbol package, including extension
public override string SymbolPackageName => System.IO.Path.ChangeExtension(PackageFileName, ".snupkg");
public override string SymbolPackageName => SIO.Path.ChangeExtension(PackageFileName, ".snupkg");
// The directory into which this package is installed
public override string PackageInstallDirectory => BuildSettings.ChocolateyTestDirectory;
// The directory used to contain results of package tests for this package
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions cake/constants.cake → recipe/constants.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// This file contains both real constants and static readonly variables used
// as constants. All values are initialized before any instance variables.

// Alias used throughout the recipe
using SIO = System.IO;

// GitHub owner is the NUnit organization
const string GITHUB_OWNER = "nunit";

Expand Down
Loading