forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.Tests.2.cs
152 lines (122 loc) · 6.58 KB
/
Build.Tests.2.cs
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
using System.Drawing;
using System.Linq;
using Colorful;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.ProjectModel.ProjectModelTasks;
partial class Build
{
Target TestGreenDonut => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "GreenDonut" / "GreenDonut.sln"));
Target TestHotChocolateAnalyzers => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Analyzers" / "HotChocolate.Analyzers.sln"));
Target TestHotChocolateApolloFederation => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "ApolloFederation" / "HotChocolate.ApolloFederation.sln"));
Target TestHotChocolateAspNetCore => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "AspNetCore" / "HotChocolate.AspNetCore.sln"));
Target TestHotChocolateAzureFunctions => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "AzureFunctions" / "HotChocolate.AzureFunctions.sln"));
Target TestHotChocolateCodeGeneration => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "CodeGeneration" / "HotChocolate.CodeGeneration.sln"));
Target TestHotChocolateCore => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Core" / "HotChocolate.Core.sln"));
Target TestHotChocolateData => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Data" / "HotChocolate.Data.sln"));
Target TestHotChocolateDiagnostics => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Diagnostics" / "HotChocolate.Diagnostics.sln"));
Target TestHotChocolateFilters => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Filters" / "HotChocolate.Filters.sln"));
Target TestHotChocolateFusion => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Fusion" / "HotChocolate.Fusion.sln"));
Target TestHotChocolateLanguage => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Language" / "HotChocolate.Language.sln"));
Target TestHotChocolateMongoDb => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "MongoDb" / "HotChocolate.MongoDb.sln"));
Target TestHotChocolateNeo4J => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Neo4J" / "HotChocolate.Neo4J.sln"));
Target TestHotChocolatePersistedQueries => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "PersistedQueries" / "HotChocolate.PersistedQueries.sln"));
Target TestHotChocolateSpatial => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Spatial" / "HotChocolate.Spatial.sln"));
Target TestHotChocolateStitching => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Stitching" / "HotChocolate.Stitching.sln"));
Target TestHotChocolateUtilities => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Utilities" / "HotChocolate.Utilities.sln"));
Target TestHotChocolateCaching => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "HotChocolate" / "Caching" / "HotChocolate.Caching.sln"));
Target TestStrawberryShakeClient => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "StrawberryShake" / "Client" / "StrawberryShake.Client.sln"));
Target TestStrawberryShakeCodeGeneration => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunTests(SourceDirectory / "StrawberryShake" / "CodeGeneration" / "StrawberryShake.CodeGeneration.sln"));
Target TestStrawberryShakeTooling => _ => _
.Produces(TestResultDirectory / "*.trx")
.Executes(() => RunClientTests(SourceDirectory / "StrawberryShake" / "Tooling" / "StrawberryShake.Tooling.sln"));
void RunClientTests(AbsolutePath solutionFile)
{
RunTests(solutionFile);
}
void RunTests(AbsolutePath solutionFile)
{
var solutionDirectory = solutionFile.Parent!;
var testDirectory = solutionDirectory / "test";
DotNetBuild(c => c
.SetProjectFile(solutionFile)
.SetConfiguration(Debug));
// we only select test projects that are located in the solutions test directory.
// this will ensure that on build we do not execute referenced tests from other solutions.
var testProjects = ParseSolution(solutionFile)
.GetProjects("*.Tests")
.Where(t => t.Path.ToString().StartsWith(testDirectory))
.ToArray();
Console.WriteLine("╬============================================");
Console.WriteLine("║ Prepared Tests:");
Console.WriteLine($"║ {RootDirectory.GetRelativePathTo(solutionDirectory)}:");
foreach (var testProject in testProjects)
{
Console.WriteLine($"║ - {RootDirectory.GetRelativePathTo( testProject.Path.Parent!)}:");
}
Console.WriteLine("╬================================");
try
{
DotNetTest(
c => c
.SetProjectFile(solutionFile)
.SetConfiguration(Debug)
.SetNoRestore(true)
.SetNoBuild(true)
.ResetVerbosity()
.SetResultsDirectory(TestResultDirectory)
.CombineWith(testProjects, (_, v) => _
.SetProjectFile(v)
.SetLoggers($"trx;LogFileName={v.Name}.trx")));
}
finally
{
UploadTestsAndMismatches();
}
}
}