forked from microsoft/scalar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
122 lines (105 loc) · 4.33 KB
/
Program.cs
File metadata and controls
122 lines (105 loc) · 4.33 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
115
116
117
118
119
120
121
122
using Scalar.FunctionalTests.Properties;
using Scalar.FunctionalTests.Tools;
using Scalar.Tests;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace Scalar.FunctionalTests
{
public class Program
{
public static void Main(string[] args)
{
Properties.Settings.Default.Initialize();
NUnitRunner runner = new NUnitRunner(args);
runner.AddGlobalSetupIfNeeded("Scalar.FunctionalTests.GlobalSetup");
if (runner.HasCustomArg("--no-shared-scalar-cache"))
{
Console.WriteLine("Running without a shared git object cache");
ScalarTestConfig.NoSharedCache = true;
}
if (runner.HasCustomArg("--test-git-on-path"))
{
Console.WriteLine("Running tests against Git on path");
ScalarTestConfig.TestGitOnPath = true;
}
if (runner.HasCustomArg("--test-scalar-on-path"))
{
Console.WriteLine("Running tests against Scalar on path");
ScalarTestConfig.TestScalarOnPath = true;
}
string trace2Output = runner.GetCustomArgWithParam("--trace2-output");
if (trace2Output != null)
{
Console.WriteLine($"Sending trace2 output to {trace2Output}");
Environment.SetEnvironmentVariable("GIT_TRACE2_EVENT", trace2Output);
}
ScalarTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-scalar-cache-root");
HashSet<string> includeCategories = new HashSet<string>();
HashSet<string> excludeCategories = new HashSet<string>();
// Run all GitRepoTests with sparse mode
ScalarTestConfig.GitRepoTestsValidateWorkTree =
new object[]
{
new object[] { Settings.ValidateWorkingTreeMode.SparseMode },
};
if (runner.HasCustomArg("--full-suite"))
{
Console.WriteLine("Running the full suite of tests");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllMacRunners;
}
}
else
{
ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
excludeCategories.Add(Categories.MacTODO.TestNeedsToLockFile);
excludeCategories.Add(Categories.WindowsOnly);
}
else
{
excludeCategories.Add(Categories.MacOnly);
}
// For now, run all of the tests not flagged as needing to be updated to work
// with the non-virtualized solution
excludeCategories.Add(Categories.NeedsUpdatesForNonVirtualizedMode);
ScalarTestConfig.RepoToClone =
runner.GetCustomArgWithParam("--repo-to-clone")
?? Properties.Settings.Default.RepoToClone;
RunBeforeAnyTests();
Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);
try
{
// Shutdown the watchman server now that the tests are complete.
// Allows deleting the unwatched directories.
ProcessHelper.Run("watchman", "shutdown-server");
}
catch (Exception)
{
// This is non-critical, and watchman may not be installed.
}
if (Debugger.IsAttached)
{
Console.WriteLine("Tests completed. Press Enter to exit.");
Console.ReadLine();
}
}
private static void RunBeforeAnyTests()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ScalarServiceProcess.InstallService();
}
}
}
}