-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cake
More file actions
114 lines (93 loc) · 4.24 KB
/
Copy pathbuild.cake
File metadata and controls
114 lines (93 loc) · 4.24 KB
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
// Load the recipe
#load nuget:?package=NUnit.Cake.Recipe&version=2.0.0-beta.4.2
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../NUnit.Cake.Recipe/src/NUnit.Cake.Recipe/content/*.cake
// Load additional cake files
#load KnownExtensions.cake
// Initialize BuildSettings
BuildSettings.Initialize(
Context,
title: "NUnit Engine API",
githubRepository: "NUnit.Engine.Api",
solutionFile: "NUnit.Engine.Api.sln",
buildWithMSBuild: true);
//////////////////////////////////////////////////////////////////////
// INDIVIDUAL PACKAGE DEFINITIONS
//////////////////////////////////////////////////////////////////////
BuildSettings.Packages.Add(new NuGetPackage(
id: "NUnit.Engine.Api",
source: BuildSettings.SourceDirectory + "NUnit.Engine.Api/NUnit.Engine.Api.csproj",
checks: new PackageCheck[] {
HasFile("LICENSE.txt"),
HasDirectory("lib/net462").WithFile("nunit.engine.api.dll"),
HasDirectory("lib/netstandard2.0").WithFile("nunit.engine.api.dll"),
HasDependency("NUnit.Extensibility.Api", "4.0.0-beta.2.2")
},
symbols: new PackageCheck[] {
HasDirectory("lib/net462").WithFile("nunit.engine.api.pdb"),
HasDirectory("lib/netstandard2.0").WithFile("nunit.engine.api.pdb")
}));
Task("BuildPackages")
.Description("Just build packages, without installing or running package tests")
.IsDependentOn("Build")
.Does(() =>
{
foreach (var package in BuildSettings.Packages)
package.BuildPackage();
});
//////////////////////////////////////////////////////////////////////
// CONSOLE PACKAGE TEST RUNNER
//////////////////////////////////////////////////////////////////////
// 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, bool redirectOutput)
{
Console.WriteLine($"Running package test with arguments {arguments}");
return base.RunPackageTest(_executablePath, new ProcessSettings() { Arguments = arguments, RedirectStandardOutput = redirectOutput });
}
}
//////////////////////////////////////////////////////////////////////
// AGENT CORE PACKAGE TEST RUNNER
//////////////////////////////////////////////////////////////////////
public class DirectTestAgentRunner : TestRunner, IPackageTestRunner
{
public int RunPackageTest(string arguments, bool redirectOutput)
{
// First argument must be relative path to a test assembly.
// It's immediate directory name is the name of the runtime.
string testAssembly = arguments.Trim();
testAssembly = BuildSettings.OutputDirectory + (testAssembly[0] == '"'
? testAssembly.Substring(1, testAssembly.IndexOf('"', 1) - 1)
: testAssembly.Substring(0, testAssembly.IndexOf(' ')));
if (!System.IO.File.Exists(testAssembly))
throw new FileNotFoundException($"File not found: {testAssembly}");
string testRuntime = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(testAssembly));
string agentRuntime = testRuntime;
if (agentRuntime.EndsWith("-windows"))
agentRuntime = agentRuntime.Substring(0, 6);
// Avoid builds we don't have
if (agentRuntime == "net35")
agentRuntime = "net20";
else if (agentRuntime == "net5.0")
agentRuntime = "net6.0";
var executablePath = BuildSettings.OutputDirectory + $"{agentRuntime}/DirectTestAgent.exe";
if (!System.IO.File.Exists(executablePath))
throw new FileNotFoundException($"File not found: {executablePath}");
Console.WriteLine($"Trying to run {executablePath} with arguments {arguments}");
return BuildSettings.Context.StartProcess(executablePath, new ProcessSettings()
{
Arguments = arguments,
WorkingDirectory = BuildSettings.OutputDirectory
});
}
}
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
Build.Run()