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

Erase empty log files from older runners #64

Merged
merged 1 commit into from
Jun 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
29 changes: 12 additions & 17 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,7 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.18.0-dev00037
#tool nuget:?package=NUnit.ConsoleRunner.NetCore&version=3.18.0-dev00037

////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////

const string SOLUTION_FILE = "nunit-project-loader.sln";
const string NUGET_ID = "NUnit.Extension.NUnitProjectLoader";
const string CHOCO_ID = "nunit-extension-nunit-project-loader";
const string GITHUB_OWNER = "nunit";
const string GITHUB_REPO = "nunit-project-loader";
const string DEFAULT_CONFIGURATION = "Release";
// Make sure that all the following console versions are installed using #tool
// For the net core runner, prefix version here with "NetCore" e.g.: "NetCore.3.7.1"
static readonly string[] CONSOLE_VERSIONS_FOR_PACKAGE_TESTS = new string[] { "3.17.0", "3.15.5", "3.18.0-dev00037" };
const string CONSOLE_VERSION_FOR_UNIT_TESTS = "3.17.0";

// Load scripts after defining constants
// Load scripts
#load cake/parameters.cake

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -71,6 +56,8 @@ Task("Clean")
CleanDirectory(parameters.OutputDirectory);
Information("Cleaning " + parameters.PackageDirectory);
CleanDirectory(parameters.PackageDirectory);
Information("Deleting log files");
DeleteFiles(parameters.ProjectDirectory + "*.log");
});

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -133,6 +120,8 @@ Task("TestNet462")
{
string runner = parameters.ToolsDirectory + $"NUnit.ConsoleRunner.{CONSOLE_VERSION_FOR_UNIT_TESTS}/tools/nunit3-console.exe";
StartProcess(runner, parameters.OutputDirectory + "net462/nunit-project-loader.tests.dll");
// We will have empty logs so long as we test against 3.15.5 and 3.17.0
DeleteEmptyLogFiles(parameters.ProjectDirectory);
});

Task("TestNet60")
Expand Down Expand Up @@ -173,7 +162,7 @@ Task("VerifyNuGetPackage")
.Does<BuildParameters>((parameters) =>
{
Check.That(parameters.NuGetInstallDirectory,
HasFiles("CHANGES.md", "LICENSE.txt"),
HasFiles("CHANGES.md", "LICENSE.txt", "nunit_256.png"),
HasDirectory("tools/net20").WithFiles("nunit-project-loader.dll", "nunit.engine.api.dll"));
Information("Verification was successful!");
});
Expand All @@ -183,6 +172,9 @@ Task("TestNuGetPackage")
.Does<BuildParameters>((parameters) =>
{
new NuGetPackageTester(parameters).RunPackageTests(PackageTests);

// We will have empty logs so long as we test against 3.15.5 and 3.17.0
DeleteEmptyLogFiles(parameters.ProjectDirectory);
});

Task("BuildChocolateyPackage")
Expand Down Expand Up @@ -224,6 +216,9 @@ Task("TestChocolateyPackage")
.Does<BuildParameters>((parameters) =>
{
new ChocolateyPackageTester(parameters).RunPackageTests(PackageTests);

// We will have empty logs so long as we test against 3.15.5 and 3.17.0
DeleteEmptyLogFiles(parameters.ProjectDirectory);
});

PackageTest[] PackageTests = new PackageTest[]
Expand Down
15 changes: 15 additions & 0 deletions cake/constants.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////

const string SOLUTION_FILE = "nunit-project-loader.sln";
const string NUGET_ID = "NUnit.Extension.NUnitProjectLoader";
const string CHOCO_ID = "nunit-extension-nunit-project-loader";
const string GITHUB_OWNER = "nunit";
const string GITHUB_REPO = "nunit-project-loader";
const string DEFAULT_CONFIGURATION = "Release";
// Make sure that all the following console versions are installed using #tool
// For the net core runner, prefix version here with "NetCore" e.g.: "NetCore.3.7.1"
static readonly string[] CONSOLE_VERSIONS_FOR_PACKAGE_TESTS = new string[] { "3.17.0", "3.15.5", "3.18.0-dev00037" };
const string CONSOLE_VERSION_FOR_UNIT_TESTS = "3.17.0";

6 changes: 2 additions & 4 deletions cake/packaging.cake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void BuildNuGetPackage(BuildParameters parameters)
var content = new List<NuSpecContent>();
content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "LICENSE.txt" });
content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "CHANGES.md" });
content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "nunit_256.png" });
content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "nunit-project-loader.addins", Target = "tools" });
content.Add(new NuSpecContent { Source = parameters.OutputDirectory + "net20/nunit-project-loader.dll", Target = "tools/net20" });
content.Add(new NuSpecContent { Source = parameters.OutputDirectory + "net20/nunit.engine.api.dll", Target = "tools/net20" });
Expand All @@ -47,15 +48,12 @@ public void BuildNuGetPackage(BuildParameters parameters)
Description = DESCRIPTION,
Summary = SUMMARY,
ProjectUrl = PROJECT_URL,
IconUrl = ICON_URL,
//Icon = "nunit.ico", // Waiting for Cake release
Icon = "nunit_256.png",
License = new NuSpecLicense() { Type = "expression", Value = "MIT" },
//LicenseUrl = LICENSE_URL,
RequireLicenseAcceptance = false,
Copyright = COPYRIGHT,
ReleaseNotes = RELEASE_NOTES,
Tags = TAGS,
//Language = "en-US",
OutputDirectory = parameters.PackageDirectory,
KeepTemporaryNuSpecFile = false,
Files = content
Expand Down
3 changes: 2 additions & 1 deletion cake/parameters.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#load "./versioning.cake"
#load "./constants.cake"
#load "./versioning.cake"
#load "./packaging.cake"
#load "./package-checks.cake"
#load "./package-tests.cake"
Expand Down
12 changes: 12 additions & 0 deletions cake/utilities.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// GLOBALLY ACCESSIBLE UTILITY METHODS
//////////////////////////////////////////////////////////////////////

// These stand-alone utility methods are only visible from within the
// code for defined Tasks.

public void DeleteObjectDirectories(BuildParameters parameters)
{
string pattern = parameters.SourceDirectory + "**/obj/";
Expand All @@ -28,3 +31,12 @@ private void CheckPackageExists(FilePath package)
throw new InvalidOperationException(
$"Package not found: {package.GetFilename()}.\nCode may have changed since package was last built.");
}

private void DeleteEmptyLogFiles(string directory)
{
DirectoryInfo info = new DirectoryInfo(directory);

foreach (var file in info.GetFiles("*.log"))
if (file.Length == 0)
System.IO.File.Delete(file.FullName);
}
1 change: 1 addition & 0 deletions nunit-project-loader.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
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{1E689680-AB9D-497E-8FC3-B541A9A24EEC}"
ProjectSection(SolutionItems) = preProject
cake\constants.cake = cake\constants.cake
cake\local-targets.cake = cake\local-targets.cake
cake\package-checks.cake = cake\package-checks.cake
cake\package-tests.cake = cake\package-tests.cake
Expand Down
Binary file added nunit_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.