Skip to content

Commit 4699e8d

Browse files
authored
Merge pull request #1434 from nunit/cakeupdates
Cakeupdates
2 parents 2039dd8 + 4c8e282 commit 4699e8d

File tree

11 files changed

+268
-15
lines changed

11 files changed

+268
-15
lines changed

.claude/settings.local.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "4.0.0",
6+
"version": "6.1.0",
77
"commands": [
88
"dotnet-cake"
99
]
1010
},
1111
"minver-cli": {
12-
"version": "4.3.0",
12+
"version": "7.0.0",
1313
"commands": [
1414
"minver"
1515
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
<CodeAnalysisRuleSet>..\Osiris.Extended.ruleset</CodeAnalysisRuleSet>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
15+
<PackageReference Include="NUnit" />
16+
<PackageReference Include="NUnit3TestAdapter" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\CakeScripts\CakeScripts.csproj" />
21+
</ItemGroup>
22+
23+
</Project>

CakeScripts.Tests/GlobalUsings.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ***********************************************************************
2+
// Copyright (c) 2011-2021 Charlie Poole, Terje Sandstrom
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining
5+
// a copy of this software and associated documentation files (the
6+
// "Software"), to deal in the Software without restriction, including
7+
// without limitation the rights to use, copy, modify, merge, publish,
8+
// distribute, sublicense, and/or sell copies of the Software, and to
9+
// permit persons to whom the Software is furnished to do so, subject to
10+
// the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be
13+
// included in all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// ***********************************************************************
23+
24+
global using NUnit.Framework;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// ***********************************************************************
2+
// Copyright (c) 2011-2021 Charlie Poole, Terje Sandstrom
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining
5+
// a copy of this software and associated documentation files (the
6+
// "Software"), to deal in the Software without restriction, including
7+
// without limitation the rights to use, copy, modify, merge, publish,
8+
// distribute, sublicense, and/or sell copies of the Software, and to
9+
// permit persons to whom the Software is furnished to do so, subject to
10+
// the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be
13+
// included in all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// ***********************************************************************
23+
24+
namespace CakeScripts.Tests;
25+
26+
public class MinVerToolTests
27+
{
28+
[Test]
29+
public void GetVersion_ReturnsNonEmptyVersion()
30+
{
31+
var version = MinVerTool.GetVersion();
32+
33+
Assert.That(version, Is.Not.Null.And.Not.Empty);
34+
}
35+
36+
[Test]
37+
public void GetVersion_ReturnsValidSemVerFormat()
38+
{
39+
var version = MinVerTool.GetVersion();
40+
41+
// Should match semver pattern: major.minor.patch or major.minor.patch-prerelease
42+
Assert.That(version, Does.Match(@"^\d+\.\d+\.\d+(-[\w.]+)?$"));
43+
}
44+
45+
[Test]
46+
public void GetVersion_WithMinorAutoIncrement_ReturnsVersion()
47+
{
48+
var version = MinVerTool.GetVersion(AutoIncrement.Minor);
49+
50+
Assert.That(version, Is.Not.Null.And.Not.Empty);
51+
}
52+
53+
[Test]
54+
public void GetVersion_WithMajorAutoIncrement_ReturnsVersion()
55+
{
56+
var version = MinVerTool.GetVersion(AutoIncrement.Major);
57+
58+
Assert.That(version, Is.Not.Null.And.Not.Empty);
59+
}
60+
61+
[Test]
62+
public void GetVersion_WithPatchAutoIncrement_ReturnsVersion()
63+
{
64+
var version = MinVerTool.GetVersion(AutoIncrement.Patch);
65+
66+
Assert.That(version, Is.Not.Null.And.Not.Empty);
67+
}
68+
69+
[Test]
70+
public void GetVersion_WithCustomTagPrefix_ReturnsVersion()
71+
{
72+
var version = MinVerTool.GetVersion(tagPrefix: "v");
73+
74+
Assert.That(version, Is.Not.Null.And.Not.Empty);
75+
}
76+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ***********************************************************************
2+
// Copyright (c) 2011-2021 Charlie Poole, Terje Sandstrom
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining
5+
// a copy of this software and associated documentation files (the
6+
// "Software"), to deal in the Software without restriction, including
7+
// without limitation the rights to use, copy, modify, merge, publish,
8+
// distribute, sublicense, and/or sell copies of the Software, and to
9+
// permit persons to whom the Software is furnished to do so, subject to
10+
// the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be
13+
// included in all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// ***********************************************************************
23+
24+
namespace CakeScripts.Tests;
25+
26+
public class VersionParsersTests
27+
{
28+
[TestCase("1.0.0", ExpectedResult = "1.0.0.0")]
29+
[TestCase("2.3.4", ExpectedResult = "2.3.4.0")]
30+
[TestCase("1.0.0-alpha", ExpectedResult = "1.0.0.0")]
31+
[TestCase("2.3.4-beta.1", ExpectedResult = "2.3.4.0")]
32+
[TestCase("6.2.0-alpha.0.17", ExpectedResult = "6.2.0.0")]
33+
[TestCase("1.2.3-rc.1.5", ExpectedResult = "1.2.3.0")]
34+
public string ParseAssemblyVersion_ReturnsCorrectVersion(string version)
35+
{
36+
return VersionParsers.ParseAssemblyVersion(version);
37+
}
38+
39+
[Test]
40+
public void ParseAssemblyVersion_WithoutPreRelease_AppendsDotZero()
41+
{
42+
var result = VersionParsers.ParseAssemblyVersion("1.2.3");
43+
Assert.That(result, Is.EqualTo("1.2.3.0"));
44+
}
45+
46+
[Test]
47+
public void ParseAssemblyVersion_WithPreRelease_StripsPreReleaseAndAppendsDotZero()
48+
{
49+
var result = VersionParsers.ParseAssemblyVersion("1.2.3-preview.5");
50+
Assert.That(result, Is.EqualTo("1.2.3.0"));
51+
}
52+
}

CakeScripts/CakeScripts.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsPackable>false</IsPackable>
9+
<CodeAnalysisRuleSet>..\Osiris.Extended.ruleset</CodeAnalysisRuleSet>
10+
</PropertyGroup>
11+
12+
</Project>

CakeScripts/MinVerTool.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ***********************************************************************
2+
// Copyright (c) 2011-2021 Charlie Poole, 2014-2026 Terje Sandstrom
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining
5+
// a copy of this software and associated documentation files (the
6+
// "Software"), to deal in the Software without restriction, including
7+
// without limitation the rights to use, copy, modify, merge, publish,
8+
// distribute, sublicense, and/or sell copies of the Software, and to
9+
// permit persons to whom the Software is furnished to do so, subject to
10+
// the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be
13+
// included in all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// ***********************************************************************
23+
24+
using System.Diagnostics;
25+
26+
public enum AutoIncrement
27+
{
28+
Major,
29+
Minor,
30+
Patch,
31+
}
32+
33+
public static class MinVerTool
34+
{
35+
public static string GetVersion(AutoIncrement autoIncrement = AutoIncrement.Minor, string tagPrefix = "v")
36+
{
37+
var startInfo = new ProcessStartInfo
38+
{
39+
FileName = "dotnet",
40+
Arguments = $"minver --auto-increment {autoIncrement.ToString().ToLower()} --tag-prefix {tagPrefix}",
41+
RedirectStandardOutput = true,
42+
UseShellExecute = false,
43+
CreateNoWindow = true,
44+
};
45+
46+
using var process = Process.Start(startInfo) ?? throw new InvalidOperationException("Failed to start minver process");
47+
var output = process.StandardOutput.ReadToEnd().Trim();
48+
process.WaitForExit();
49+
50+
return output;
51+
}
52+
}

CakeScripts/VersionParsers.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
1+
// ***********************************************************************
2+
// Copyright (c) 2011-2021 Charlie Poole, 2014-2026 Terje Sandstrom
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining
5+
// a copy of this software and associated documentation files (the
6+
// "Software"), to deal in the Software without restriction, including
7+
// without limitation the rights to use, copy, modify, merge, publish,
8+
// distribute, sublicense, and/or sell copies of the Software, and to
9+
// permit persons to whom the Software is furnished to do so, subject to
10+
// the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be
13+
// included in all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// ***********************************************************************
223

324
public static class VersionParsers
425
{
@@ -9,6 +30,7 @@ public static string ParseAssemblyVersion(string version)
930
{
1031
return string.Concat(version.AsSpan(0, dash), ".0");
1132
}
33+
1234
return version + ".0";
1335
}
1436
}

NUnit3TestAdapter.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@
4747
<Project Path="src/NUnit3AdapterExternalTests/NUnit3AdapterExternalTests.csproj" />
4848
<Project Path="src/NUnitTestAdapter/NUnit.TestAdapter.csproj" />
4949
<Project Path="src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj" />
50+
<Project Path="CakeScripts/CakeScripts.csproj" />
51+
<Project Path="CakeScripts.Tests/CakeScripts.Tests.csproj" />
5052
</Solution>

0 commit comments

Comments
 (0)