Skip to content

Commit c06fb2e

Browse files
authored
Merge pull request #135 from Unity-Technologies/new-options
New command line test abilities
2 parents e6ec138 + c8297e8 commit c06fb2e

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

unity/CITools/BuildDriver/Program.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static async Task<int> Main(string[] args)
1212
string configuration = "Release";
1313
bool silent = false;
1414
bool skipBuild = false;
15-
bool test = false;
15+
TestTargets testTargets = TestTargets.None;
1616
bool zip = RunningOnYamato();
1717
Task<NPath>? zipTask = null;
1818
foreach (string arg in args)
@@ -32,10 +32,21 @@ public static async Task<int> Main(string[] args)
3232
else if (arg.Equals("--test"))
3333
{
3434
skipBuild = true; // Assume we've already built
35-
test = true;
35+
testTargets = TestTargets.All;
36+
}
37+
else if (arg.StartsWith("--test="))
38+
{
39+
if (!TryParseTestTargets(arg, out var testTarget))
40+
return 1;
41+
skipBuild = true; // Assume we've already built
42+
testTargets = Enum.Parse<TestTargets>(testTarget, ignoreCase: true);
3643
}
3744
}
3845

46+
// This gives a way to test and build in the same command
47+
if (args.Any(a => a == "--build"))
48+
skipBuild = false;
49+
3950
if (RunningOnYamato())
4051
{
4152
zipTask = SevenZip.DownloadAndUnzip7Zip();
@@ -70,10 +81,14 @@ public static async Task<int> Main(string[] args)
7081
SevenZip.Zip(zipExe, artifacts, gConfig);
7182
}
7283

73-
if (test)
84+
if (testTargets != TestTargets.None)
7485
{
75-
EmbeddingHost.Test(gConfig);
76-
CoreCLR.Test(gConfig);
86+
if (testTargets.HasFlag(TestTargets.Embedding))
87+
EmbeddingHost.Test(gConfig);
88+
89+
if (testTargets.HasFlag(TestTargets.CoreClr))
90+
CoreCLR.Test(gConfig);
91+
7792
Console.WriteLine("******************************");
7893
Console.WriteLine("Unity: Tested CoreCLR successfully");
7994
Console.WriteLine("******************************");
@@ -110,6 +125,16 @@ static NPath ConsolidateArtifacts(GlobalConfig gConfig)
110125
return destDir;
111126
}
112127

128+
static bool TryParseTestTargets(string arg, out string value)
129+
{
130+
var values = Enum.GetValues(typeof(TestTargets));
131+
var valid = new List<string>();
132+
foreach(var v in values)
133+
valid.Add(v.ToString().ToLower());
134+
135+
return TryParseArgument(valid.ToArray(), arg, out value);
136+
}
137+
113138
static bool TryParseArgument(string[] validArgs, string arg, out string value)
114139
{
115140
string[] args = arg.Split('=');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace BuildDriver;
5+
6+
[Flags]
7+
public enum TestTargets
8+
{
9+
None = 1 << 0,
10+
Embedding = 1 << 1,
11+
CoreClr = 1 << 2,
12+
All = ~0
13+
}

0 commit comments

Comments
 (0)