Skip to content

Commit 8287632

Browse files
committed
Tweak the testing to support matrix tests
1 parent c107e5b commit 8287632

File tree

5 files changed

+51
-44
lines changed

5 files changed

+51
-44
lines changed

build/Build.CalamariTesting.cs

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

build/Build.TestCalamariFlavourProject.cs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,56 @@ namespace Calamari.Build;
44

55
partial class Build
66
{
7-
[Parameter(Name = "CalamariFlavour")] readonly string? CalamariFlavourToTest;
8-
[Parameter(Name = "VSTest_TestCaseFilter")] readonly string? CalamariFlavourTestCaseFilter;
7+
[Parameter(Name = "ProjectToTest")] readonly string? CalamariProjectToTest;
8+
9+
[PublicAPI]
10+
Target LinuxHostTests =>
11+
target => target
12+
.Executes(async () =>
13+
{
14+
var dotnetPath = await LocateOrInstallDotNetSdk();
15+
16+
var project = CalamariProjectToTest ?? "Calamari";
917

18+
var dll = $"TestBinaries/{project}.Tests.dll";
19+
20+
CreateTestRun(dll)
21+
.WithDotNetPath(dotnetPath)
22+
.WithFilter("TestCategory != Windows") // Linux is all tests that are non-Windows specific
23+
.Execute();
24+
});
25+
1026
[PublicAPI]
11-
Target TestCalamariFlavourProject =>
27+
Target WindowsHostTests =>
1228
target => target
1329
.Executes(async () =>
1430
{
1531
var dotnetPath = await LocateOrInstallDotNetSdk();
1632

17-
CreateTestRun($"CalamariTests/Calamari.{CalamariFlavourToTest}.Tests.dll")
33+
var project = CalamariProjectToTest ?? "Calamari";
34+
35+
var dll = $"TestBinaries/{project}.Tests.dll";
36+
37+
CreateTestRun(dll)
38+
.WithDotNetPath(dotnetPath)
39+
.WithFilter("TestCategory != Linux && TestCategory != MacOs") // Windows is all tests that are non-Linux or MacOS specific
40+
.Execute();
41+
});
42+
43+
[PublicAPI]
44+
Target Windows2026OrLaterHostTests =>
45+
target => target
46+
.Executes(async () =>
47+
{
48+
var dotnetPath = await LocateOrInstallDotNetSdk();
49+
50+
var project = CalamariProjectToTest ?? "Calamari";
51+
52+
var dll = $"TestBinaries/{project}.Tests.dll";
53+
54+
CreateTestRun(dll)
1855
.WithDotNetPath(dotnetPath)
19-
.WithFilter(CalamariFlavourTestCaseFilter)
56+
.WithFilter("TestCategory == Windows2016OrLater") // Windows 2016 or later specific tests
2057
.Execute();
2158
});
2259
}

source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
namespace Calamari.AzureResourceGroup.Tests
1919
{
2020
[TestFixture]
21+
[Category(TestCategories.Windows2016OrLater)]
22+
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
2123
[TestPlatforms(TestPlatforms.Windows)] // NOTE: We should look at having the Azure CLI installed on Linux boxes so that these steps can be tested there, particularly if we're moving cloud to a Ubuntu Default Worker.
2224
class DeployAzureBicepTemplateCommandFixture
2325
{
@@ -93,7 +95,6 @@ await armClient.GetResourceGroupResource(ResourceGroupResource.CreateResourceIde
9395
}
9496

9597
[Test]
96-
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
9798
public async Task DeployAzureBicepTemplate_PackageSource()
9899
{
99100
await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
@@ -108,7 +109,6 @@ await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
108109
}
109110

110111
[Test]
111-
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
112112
public async Task DeployAzureBicepTemplate_GitSource()
113113
{
114114
// For the purposes of Bicep templates in Calamari, a template in a Git Repository
@@ -127,7 +127,6 @@ await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
127127
}
128128

129129
[Test]
130-
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
131130
public async Task DeployAzureBicepTemplate_InlineSource()
132131
{
133132
var templateFileContent = File.ReadAllText(Path.Combine(packagePath, "azure_website_template.bicep"));

source/Calamari.Testing/Requirements/RequiresWindowsServer2016OrAboveAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Calamari.Testing.Requirements;
66

7-
public class RequiresWindowsServer2016OrAboveAttribute(string reason) : TestAttribute, ITestAction
7+
public class RequiresWindowsServer2016OrAboveAttribute(string reason) : NUnitAttribute, ITestAction
88
{
99
public void BeforeTest(ITest testDetails)
1010
{
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Calamari.Testing;
2+
3+
public static class TestCategories
4+
{
5+
public const string Windows2016OrLater = "Windows2016OrLater";
6+
}

0 commit comments

Comments
 (0)