forked from nunit/nunit-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
233 lines (207 loc) · 10.7 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
// Load the recipe
#load nuget:?package=NUnit.Cake.Recipe&version=1.3.0
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../NUnit.Cake.Recipe/recipe/*.cake
#load package-tests.cake
// Initialize BuildSettings
BuildSettings.Initialize(
Context,
title: "NUnit Console and Engine",
githubRepository: "nunit-console",
solutionFile: "NUnitConsole.sln",
exemptFiles: new[] { "Options.cs", "ProcessUtils.cs", "ProcessUtilsTests.cs" });
//////////////////////////////////////////////////////////////////////
// LISTS OF FILES USED IN CHECKING PACKAGES
//////////////////////////////////////////////////////////////////////
FilePath[] ConsoleFiles = {
"nunit3-console.dll", "nunit3-console.dll.config", "nunit3-console.exe", "nunit3-console.pdb",
"nunit3-console.deps.json", "nunit3-console.runtimeconfig.json" };
FilePath[] ENGINE_FILES = {
"nunit.engine.dll", "nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll" };
FilePath[] ENGINE_PDB_FILES = {
"nunit.engine.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] ENGINE_CORE_FILES = {
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll" };
FilePath[] ENGINE_CORE_PDB_FILES = {
"nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] AGENT_FILES = {
"nunit-agent.exe", "nunit-agent.exe.config",
"nunit-agent-x86.exe", "nunit-agent-x86.exe.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll"};
FilePath[] AGENT_FILES_NETCORE = {
"nunit-agent.dll", "nunit-agent.dll.config",
"nunit.engine.core.dll", "nunit.engine.api.dll", "testcentric.engine.metadata.dll",
"Microsoft.Extensions.DependencyModel.dll"};
FilePath[] AGENT_PDB_FILES = {
"nunit-agent.pdb", "nunit-agent-x86.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] AGENT_PDB_FILES_NETCORE = {
"nunit-agent.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
//////////////////////////////////////////////////////////////////////
// INDIVIDUAL PACKAGE DEFINITIONS
//////////////////////////////////////////////////////////////////////
PackageDefinition NUnitConsoleNuGetPackage;
PackageDefinition NUnitConsoleRunnerNuGetPackage;
PackageDefinition NUnitConsoleRunnerNetCorePackage;
PackageDefinition NUnitConsoleRunnerNet80Package;
PackageDefinition NUnitEnginePackage;
PackageDefinition NUnitEngineApiPackage;
PackageDefinition NUnitConsoleRunnerChocolateyPackage;
PackageDefinition NUnitConsoleZipPackage;
BuildSettings.Packages.AddRange(new PackageDefinition[] {
NUnitConsoleRunnerNuGetPackage = new NuGetPackage(
id: "NUnit.ConsoleRunner",
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.nuspec",
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt"),
HasDirectory("tools").WithFiles("nunit3-console.exe", "nunit3-console.exe.config").AndFiles(ENGINE_FILES),
HasDirectory("tools/agents/net462").WithFiles(AGENT_FILES),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_FILES_NETCORE),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE),
HasDirectory("tools/agents/net7.0").WithFiles(AGENT_FILES_NETCORE),
HasDirectory("tools/agents/net8.0").WithFiles(AGENT_FILES_NETCORE)
},
symbols: new PackageCheck[] {
HasDirectory("tools").WithFiles(ENGINE_PDB_FILES).AndFile("nunit3-console.pdb"),
HasDirectory("tools/agents/net462").WithFiles(AGENT_PDB_FILES),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("tools/agents/net7.0").WithFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("tools/agents/net8.0").WithFiles(AGENT_PDB_FILES_NETCORE)
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.NuGetTestDirectory
+ $"NUnit.ConsoleRunner.{BuildSettings.PackageVersion}/tools/nunit3-console.exe"),
tests: StandardRunnerTests),
// NOTE: Must follow ConsoleRunner, upon which it depends
NUnitConsoleNuGetPackage = new NuGetPackage(
id: "NUnit.Console",
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner-with-extensions.nuspec",
checks: new PackageCheck[] { HasFile("LICENSE.txt") }),
NUnitConsoleRunnerNetCorePackage = new DotNetToolPackage(
id: "NUnit.ConsoleRunner.NetCore",
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.netcore.nuspec",
checks: new PackageCheck[]
{
HasFiles("nunit.exe"),
HasDirectory(".store/nunit.consolerunner.netcore/**/tools/net8.0/any")
.WithFiles(ENGINE_FILES).AndFiles(ConsoleFiles).AndFile("Microsoft.Extensions.DependencyModel.dll")
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.NuGetTestDirectory
+ $"NUnit.ConsoleRunner.NetCore.{BuildSettings.PackageVersion}/nunit.exe"),
tests: NetCoreRunnerTests),
NUnitConsoleRunnerChocolateyPackage = new ChocolateyPackage(
id: "nunit-console-runner",
source: BuildSettings.ChocolateyDirectory + "nunit-console-runner.nuspec",
checks: new PackageCheck[] {
HasDirectory("tools").WithFiles("LICENSE.txt", "NOTICES.txt", "VERIFICATION.txt", "nunit3-console.exe", "nunit3-console.exe.config").AndFiles(ENGINE_FILES),
HasDirectory("tools/agents/net462").WithFiles(AGENT_FILES),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_FILES_NETCORE),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE),
HasDirectory("tools/agents/net7.0").WithFiles(AGENT_FILES_NETCORE),
HasDirectory("tools/agents/net8.0").WithFiles(AGENT_FILES_NETCORE)
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.ChocolateyTestDirectory
+ $"nunit-console-runner.{BuildSettings.PackageVersion}/tools/nunit3-console.exe"),
tests: StandardRunnerTests),
NUnitConsoleZipPackage = new ZipPackage(
id: "NUnit.Console",
source: BuildSettings.ZipImageDirectory,
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt", "CHANGES.txt"),
HasDirectory("bin/net462").WithFiles("nunit3-console.exe", "nunit3-console.exe.config",
"nunit3-console.pdb").AndFiles(ENGINE_FILES).AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/net462/addins").WithFiles(
"nunit.core.dll", "nunit.core.interfaces.dll", "nunit.engine.api.dll",
"nunit.v2.driver.dll", "nunit-project-loader.dll", "nunit-v2-result-writer.dll",
"teamcity-event-listener.dll", "vs-project-loader.dll"),
HasDirectory("bin/netcoreapp3.1").WithFiles(ENGINE_CORE_FILES).AndFiles(ENGINE_CORE_PDB_FILES),
HasDirectory("bin/agents/net462").WithFiles(AGENT_FILES).AndFiles(AGENT_PDB_FILES),
HasDirectory("bin/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("bin/agents/net7.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE),
HasDirectory("bin/agents/net8.0").WithFiles(AGENT_FILES_NETCORE).AndFiles(AGENT_PDB_FILES_NETCORE),
},
testRunner: new ConsoleRunnerSelfTester(BuildSettings.ZipTestDirectory
+ $"NUnit.Console.{BuildSettings.PackageVersion}/bin/net462/nunit3-console.exe"),
tests: StandardRunnerTests,
bundledExtensions: new [] {
KnownExtensions.VSProjectLoader.NuGetPackage,
KnownExtensions.NUnitProjectLoader.NuGetPackage,
KnownExtensions.NUnitV2Driver.NuGetPackage,
KnownExtensions.NUnitV2ResultWriter.NuGetPackage,
KnownExtensions.TeamCityEventListener.NuGetPackage
}),
// NOTE: Packages below this point have no direct tests
NUnitEnginePackage = new NuGetPackage(
id: "NUnit.Engine",
source: BuildSettings.NuGetDirectory + "engine/nunit.engine.nuspec",
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt"),
HasDirectory("lib/net462").WithFiles(ENGINE_FILES),
HasDirectory("lib/net8.0").WithFiles(ENGINE_FILES).AndFile("Microsoft.Extensions.DependencyModel.dll"),
HasDirectory("contentFiles/any/agents/net462").WithFiles(AGENT_FILES)
},
symbols: new PackageCheck[] {
HasDirectory("lib/net462").WithFiles(ENGINE_PDB_FILES),
HasDirectory("lib/netstandard2.0").WithFiles(ENGINE_PDB_FILES),
HasDirectory("lib/net6.0").WithFiles(ENGINE_PDB_FILES),
HasDirectory("lib/net8.0").WithFiles(ENGINE_PDB_FILES),
HasDirectory("contentFiles/any/agents/net462").WithFiles(AGENT_PDB_FILES)
}),
NUnitEngineApiPackage = new NuGetPackage(
id: "NUnit.Engine.Api",
source: BuildSettings.NuGetDirectory + "engine/nunit.engine.api.nuspec",
checks: new PackageCheck[] {
HasFile("LICENSE.txt"),
HasDirectory("lib/net462").WithFile("nunit.engine.api.dll"),
HasDirectory("lib/netstandard2.0").WithFile("nunit.engine.api.dll"),
},
symbols: new PackageCheck[] {
HasDirectory("lib/net462").WithFile("nunit.engine.api.pdb"),
HasDirectory("lib/netstandard2.0").WithFile("nunit.engine.api.pdb")
})
});
Task("BuildZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.BuildPackage();
});
Task("InstallZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.InstallPackage();
});
Task("VerifyZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.VerifyPackage();
});
Task("TestZipPackage")
.Does(() =>
{
NUnitConsoleZipPackage.RunPackageTests();
});
Task("TestNetCorePackage")
.Does(() =>
{
NUnitConsoleRunnerNetCorePackage.RunPackageTests();
});
//////////////////////////////////////////////////////////////////////
// TEST RUNNERS
//////////////////////////////////////////////////////////////////////
// Use the console runner we just built to run package tests
public class ConsoleRunnerSelfTester : TestRunner, IPackageTestRunner
{
private string _executablePath;
public ConsoleRunnerSelfTester(string executablePath)
{
_executablePath = executablePath;
}
public int RunPackageTest(string arguments)
{
Console.WriteLine("Running package test");
return base.RunTest(_executablePath, arguments);
}
}
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
Build.Run()