-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.cake
247 lines (207 loc) · 9.84 KB
/
build.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
// Load the recipe
#load nuget:?package=TestCentric.Cake.Recipe&version=1.3.3
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../TestCentric.Cake.Recipe/recipe/*.cake
using System.Xml;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Threading.Tasks;
//////////////////////////////////////////////////////////////////////
// INITIALIZE BUILD SETTINGS
//////////////////////////////////////////////////////////////////////
BuildSettings.Initialize(
Context,
"TestCentric.Engine",
solutionFile: "testcentric-engine.sln",
githubRepository: "testcentric-engine"
);
//////////////////////////////////////////////////////////////////////
// DEFINE PACKAGE TESTS
//////////////////////////////////////////////////////////////////////
// Level 1 tests are run each time we build the packages
// Level 2 tests are run for PRs and when packages will be published
// Level 3 tests are run only when publishing a release
var packageTests = new List<PackageTest>();
// Tests of single assemblies targeting each runtime we support
packageTests.Add(new PackageTest(1, "Net462Test", "Run mock-assembly.dll targeting .NET 4.6.2",
"engine-tests/net462/mock-assembly.dll",
MockAssemblyExpectedResult("Net462AgentLauncher")));
packageTests.Add(new PackageTest(1, "Net35Test", "Run mock-assembly.dll targeting .NET 3.5",
"engine-tests/net35/mock-assembly.dll",
MockAssemblyExpectedResult("Net462AgentLauncher")));
if (BuildSettings.IsLocalBuild)
{
packageTests.Add(new PackageTest(1, "NetCore31Test", "Run mock-assembly.dll targeting .NET Core 3.1",
"engine-tests/netcoreapp3.1/mock-assembly.dll",
MockAssemblyExpectedResult("Net60AgentLauncher")));
packageTests.Add(new PackageTest(1, "NetCore21Test", "Run mock-assembly.dll targeting .NET Core 2.1",
"engine-tests/netcoreapp2.1/mock-assembly.dll",
MockAssemblyExpectedResult("Net60AgentLauncher")));
packageTests.Add(new PackageTest(1, "Net50Test", "Run mock-assembly.dll targeting .NET 5.0",
"engine-tests/net5.0/mock-assembly.dll",
MockAssemblyExpectedResult("Net60AgentLauncher")));
}
packageTests.Add(new PackageTest(1, "Net60Test", "Run mock-assembly.dll targeting .NET 6.0",
"engine-tests/net6.0/mock-assembly.dll",
MockAssemblyExpectedResult("Net60AgentLauncher")));
packageTests.Add(new PackageTest(1, "Net70Test", "Run mock-assembly.dll targeting .NET 7.0",
"engine-tests/net7.0/mock-assembly.dll",
MockAssemblyExpectedResult("Net70AgentLauncher")));
packageTests.Add(new PackageTest(1, "Net80Test", "Run mock-assembly.dll targeting .NET 8.0",
"engine-tests/net8.0/mock-assembly.dll",
MockAssemblyExpectedResult("Net80AgentLauncher")));
static ExpectedResult MockAssemblyExpectedResult(params string[] agentNames)
{
int ncopies = agentNames.Length;
var assemblies = new ExpectedAssemblyResult[ncopies];
for (int i = 0; i < ncopies; i++)
assemblies[i] = new ExpectedAssemblyResult("mock-assembly.dll", agentNames[i]);
return new ExpectedResult("Failed")
{
Total = 37 * ncopies,
Passed = 23 * ncopies,
Failed = 5 * ncopies,
Warnings = 1 * ncopies,
Inconclusive = 1 * ncopies,
Skipped = 7 * ncopies,
Assemblies = assemblies
};
}
// AspNetCore Tests
if (BuildSettings.IsLocalBuild)
{
packageTests.Add(new PackageTest(1, "AspNetCore31Test", "Run test using AspNetCore under .NET Core 3.1",
"engine-tests/netcoreapp3.1/aspnetcore-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "Net60AgentLauncher") }
}));
packageTests.Add(new PackageTest(1, "AspNetCore50Test", "Run test using AspNetCore under .NET 5.0",
"engine-tests/net5.0/aspnetcore-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new[] { new ExpectedAssemblyResult("aspnetcore-test.dll", "Net60AgentLauncher") }
}));
}
packageTests.Add(new PackageTest(1, "AspNetCore60Test", "Run test using AspNetCore under .NET 6.0",
"engine-tests/net6.0/aspnetcore-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new [] { new ExpectedAssemblyResult("aspnetcore-test.dll", "Net60AgentLauncher") }
}));
packageTests.Add(new PackageTest(1, "AspNetCore70Test", "Run test using AspNetCore under .NET 7.0",
"engine-tests/net7.0/aspnetcore-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new [] { new ExpectedAssemblyResult("aspnetcore-test.dll", "Net70AgentLauncher") }
}));
// Windows Forms Tests
if (BuildSettings.IsLocalBuild)
packageTests.Add(new PackageTest(1, "Net50WindowsFormsTest", "Run test using windows forms under .NET 5.0",
"engine-tests/net5.0-windows/windows-forms-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new [] { new ExpectedAssemblyResult("windows-forms-test.dll", "Net60AgentLauncher") }
}));
packageTests.Add(new PackageTest(1, "Net60WindowsFormsTest", "Run test using windows forms under .NET 6.0",
"engine-tests/net6.0-windows/windows-forms-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new [] { new ExpectedAssemblyResult("windows-forms-test.dll", "Net60AgentLauncher") }
}));
packageTests.Add(new PackageTest(1, "Net70WindowsFormsTest", "Run test using windows forms under .NET 7.0",
"engine-tests/net7.0-windows/windows-forms-test.dll",
new ExpectedResult("Passed")
{
Assemblies = new [] { new ExpectedAssemblyResult("windows-forms-test.dll", "Net70AgentLauncher") }
}));
// Multiple Assembly Tests
packageTests.Add(new PackageTest(1, "Net35PlusNetCore21Test", "Run different builds of mock-assembly.dll together",
"engine-tests/net35/mock-assembly.dll engine-tests/net6.0/mock-assembly.dll",
MockAssemblyExpectedResult("Net462AgentLauncher", "Net60AgentLauncher")));
// TODO: Use --config option when it's supported by the extension.
// Current test relies on the fact that the Release config appears
// first in the project file.
// Disabling entirely for now
//if (BuildSettings.Configuration == "Release")
//{
// packageTests.Add(new PackageTest(1, "NUnitProjectTest", "Run an NUnit project",
// "TestProject.nunit",
// new ExpectedResult("Failed")
// {
// Assemblies = new[] {
// new ExpectedAssemblyResult("mock-assembly.dll", "Net462AgentLauncher"),
// new ExpectedAssemblyResult("mock-assembly.dll", "Net462AgentLauncher"),
// new ExpectedAssemblyResult("mock-assembly.dll", "Net60AgentLauncher"),
// new ExpectedAssemblyResult("mock-assembly.dll", "Net60AgentLauncher") }
// },
// KnownExtensions.NUnitProjectLoader));
//}
// NOTE: Package tests using a pluggable agent must be run after all tests
// that assume no pluggable agents are installed!
// TODO: Disabling NUnitV2Test until the driver works
//packageTests.Add(new PackageTest(1, "NUnitV2Test", "Run tests using the V2 framework driver",
// "v2-tests/net35/v2-test-assembly.dll --trace:Debug",
// new ExpectedResult("Failed")
// {
// Total = 28,
// Passed = 18,
// Failed = 5,
// Warnings = 0,
// Inconclusive = 1,
// Skipped = 4
// },
// KnownExtensions.NUnitV2Driver));
//////////////////////////////////////////////////////////////////////
// DEFINE PACKAGE
//////////////////////////////////////////////////////////////////////
BuildSettings.Packages.Add(new NuGetPackage(
id: "TestCentric.Engine",
//source: "src/TestEngine/testcentric.engine/testcentric.engine.csproj",
description: "This package provides the TestCentric Engine, used by runner applications to load and excute NUnit tests.",
packageContent: new PackageContent(
new FilePath[] { "../../LICENSE.txt", "../../testcentric.png" },
new DirectoryContent("lib").WithFiles(
"testcentric.engine.dll", "testcentric.engine.api.dll", "nunit.engine.api.dll",
"testcentric.metadata.dll", "testcentric.extensibility.dll", "testcentric.extensibility.api.dll", "TestCentric.InternalTrace.dll",
"testcentric.engine.pdb", "test-bed.exe", "test-bed.exe.config",
"test-bed.addins", "../../testcentric.nuget.addins")),
testRunner: new TestCentricEngineTestBed(),
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "testcentric.png"),
HasDirectory("lib").WithFiles(
"testcentric.engine.dll", "testcentric.engine.api.dll", "nunit.engine.api.dll",
"testcentric.metadata.dll", "testcentric.extensibility.dll", "testcentric.extensibility.api.dll", "TestCentric.InternalTrace.dll",
"testcentric.engine.pdb", "test-bed.exe", "test-bed.exe.config",
"test-bed.addins", "testcentric.nuget.addins")
},
tests: packageTests,
preloadedExtensions: new [] {
KnownExtensions.Net462PluggableAgent.SetVersion("2.5.1").NuGetPackage,
KnownExtensions.Net60PluggableAgent.SetVersion("2.5.1").NuGetPackage,
KnownExtensions.Net70PluggableAgent.SetVersion("2.5.1").NuGetPackage,
KnownExtensions.Net80PluggableAgent.SetVersion("2.5.1").NuGetPackage }
));
//////////////////////////////////////////////////////////////////////
// TEST BED RUNNER
//////////////////////////////////////////////////////////////////////
public class TestCentricEngineTestBed : TestRunner, IPackageTestRunner
{
private FilePath _executablePath;
public TestCentricEngineTestBed()
{
_executablePath = BuildSettings.NuGetTestDirectory + "TestCentric.Engine." + BuildSettings.PackageVersion + "/lib/test-bed.exe";
}
public int RunPackageTest(string arguments)
{
return BuildSettings.Context.StartProcess(_executablePath, new ProcessSettings()
{
Arguments = arguments,
WorkingDirectory = BuildSettings.OutputDirectory
});
}
}
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
Build.Run();