Skip to content

Commit

Permalink
Fix headers of new files; resolve conflicts; exempt generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Feb 28, 2021
1 parent 985ecd9 commit 326ebf7
Show file tree
Hide file tree
Showing 275 changed files with 450 additions and 5,627 deletions.
14 changes: 3 additions & 11 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#load package-checks.cake
#load test-results.cake
#load package-tests.cake
#load header-check.cake
#load local-tasks.cake

// Install Tools
#tool NuGet.CommandLine&version=5.3.1
Expand Down Expand Up @@ -143,17 +145,6 @@ Task("Clean")
CleanDirectory(PACKAGE_DIR);
});

// Not currently used in CI but useful for cleaning your local obj
// directories, particularly after changing the target of a project.
Task("CleanAll")
.Description("Cleans obj directories in additon to standard clean")
.IsDependentOn("Clean")
.Does(() =>
{
foreach (var dir in GetDirectories(PROJECT_DIR + "src/**/obj/"))
DeleteDirectory(dir, new DeleteDirectorySettings() { Recursive = true });
});

//////////////////////////////////////////////////////////////////////
// INITIALIZE FOR BUILD
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -205,6 +196,7 @@ MSBuildSettings CreateMSBuildSettings(string target)

Task("Build")
.Description("Builds the engine and console")
.IsDependentOn("CheckHeaders")
.IsDependentOn("UpdateAssemblyInfo")
.Does(() =>
{
Expand Down
98 changes: 98 additions & 0 deletions header-check.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//////////////////////////////////////////////////////////////////////
// CHECK FOR MISSING AND NON-STANDARD FILE HEADERS
//////////////////////////////////////////////////////////////////////

static readonly int CD_LENGTH = Environment.CurrentDirectory.Length + 1;

static readonly string[] EXEMPT_FILES = new [] {
"AssemblyInfo.cs",
"Options.cs",
"ProcessUtils.cs",
"ProcessUtilsTests.cs"
};

// Standard Header. Change this for each project as needed.
static readonly string[] STD_HDR = new [] {
"// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt"
};

Task("CheckHeaders")
.Does(() =>
{
var NoHeader = new List<FilePath>();
var NonStandard = new List<FilePath>();
var Exempted = new List<FilePath>();
int examined = 0;
foreach(var file in GetFiles("src/**/*.cs"))
{
// Ignore autogenerated files in an obj directory
if (file.ToString().Contains("/obj/"))
continue;
examined++;
var header = GetHeader(file);
if (EXEMPT_FILES.Contains(file.GetFilename().ToString()))
Exempted.Add(file);
else if (header.Count == 0)
NoHeader.Add(file);
else if (!header.SequenceEqual(STD_HDR))
NonStandard.Add(file);
}
if (NoHeader.Count > 0)
{
Information("\nFILES WITH NO HEADER\n");
foreach(var file in NoHeader)
Information(RelPathTo(file));
}
if (NonStandard.Count > 0)
{
Information("\nFILES WITH A NON-STANDARD HEADER\n");
foreach(var file in NonStandard)
{
Information(RelPathTo(file));
Information("");
foreach(string line in GetHeader(file))
Information(line);
Information("");
}
}
if (Exempted.Count > 0)
{
Information("\nEXEMPTED FILES (NO CHECK MADE)\n");
foreach(var file in Exempted)
Information(RelPathTo(file));
}
Information($"\nFiles Examined: {examined}");
Information($"Missing Headers: {NoHeader.Count}");
Information($"Non-Standard Headers: {NonStandard.Count}");
Information($"Exempted Files: {Exempted.Count}");
if (NoHeader.Count > 0 || NonStandard.Count > 0)
throw new Exception("Missing or invalid file headers found");
});

private List<string> GetHeader(FilePath file)
{
var header = new List<string>();
var lines = System.IO.File.ReadLines(file.ToString());

foreach(string line in lines)
{
if (!line.StartsWith("//"))
break;

header.Add(line);
}

return header;
}

private string RelPathTo(FilePath file)
{
return file.ToString().Substring(CD_LENGTH);
}
30 changes: 30 additions & 0 deletions local-tasks.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) The NUnit Project and distributed under the MIT License

// This file contains tasks intended to be run locally by developers
// in any NUnit project. To use these tasks in a project, copy the file
// to an accessible directory and #load it in your build.cake file.

// Since the tasks are intended for use by the NUnit Project, it follows
// certain conventions and will need to be modified for use elsewhere.

using System.Linq;

//////////////////////////////////////////////////////////////////////
// DELETE ALL OBJ DIRECTORIES
//////////////////////////////////////////////////////////////////////

Task("DeleteObjectDirectories")
.WithCriteria(BuildSystem.IsLocalBuild)
.Does(() =>
{
Information("Deleting object directories");
foreach (var dir in GetDirectories("src/**/obj/"))
DeleteDirectory(dir, new DeleteDirectorySettings() { Recursive = true });
});

// NOTE: Any project to which this file is added is required to have a 'Clean' target
Task("CleanAll")
.Description("Perform standard 'Clean' followed by deleting object directories")
.IsDependentOn("Clean")
.IsDependentOn("DeleteObjectDirectories");
24 changes: 1 addition & 23 deletions src/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
// ***********************************************************************
// Copyright (c) 2014 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************

// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
using System.Reflection;

//
Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/ConsoleVersion.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2014 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System.Reflection;

Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/nunit3-console.tests/BadFileTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2018 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System.IO;
using System.Text;
Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/nunit3-console.tests/ColorConsoleTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2014 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using NUnit.Common;
Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/nunit3-console.tests/ColorStyleTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2014 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using NUnit.Common;
Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/nunit3-console.tests/CommandLineTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2011 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using System.IO;
Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/nunit3-console.tests/ConsoleMocks.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2019 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using NSubstitute;
using NUnit.Common;
Expand Down
23 changes: 1 addition & 22 deletions src/NUnitConsole/nunit3-console.tests/ConsoleOutputTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
// ***********************************************************************
// Copyright (c) 2015 Charlie Poole, Rob Prouse
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using NUnit.Framework;
using System;
Expand Down
4 changes: 3 additions & 1 deletion src/NUnitConsole/nunit3-console.tests/ConsoleRunnerTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using System.IO;
using System.Xml;
using NSubstitute;
Expand Down
Loading

0 comments on commit 326ebf7

Please sign in to comment.