forked from microsoft/VFSForGit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
158 lines (134 loc) · 5.75 KB
/
Program.cs
File metadata and controls
158 lines (134 loc) · 5.75 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
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
using GVFS.FunctionalTests.Tests;
using GVFS.FunctionalTests.Tools;
using GVFS.Tests;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace GVFS.FunctionalTests
{
public class Program
{
public static void Main(string[] args)
{
Properties.Settings.Default.Initialize();
NUnitRunner runner = new NUnitRunner(args);
if (runner.HasCustomArg("--no-shared-gvfs-cache"))
{
Console.WriteLine("Running without a shared git object cache");
GVFSTestConfig.NoSharedCache = true;
}
if (runner.HasCustomArg("--test-gvfs-on-path"))
{
Console.WriteLine("Running tests against GVFS on path");
GVFSTestConfig.TestGVFSOnPath = true;
}
if (runner.HasCustomArg("--replace-inbox-projfs"))
{
Console.WriteLine("Tests will replace inbox ProjFS");
GVFSTestConfig.ReplaceInboxProjFS = true;
}
GVFSTestConfig.LocalCacheRoot = runner.GetCustomArgWithParam("--shared-gvfs-cache-root");
List<string> includeCategories = new List<string>();
List<string> excludeCategories = new List<string>();
if (runner.HasCustomArg("--full-suite"))
{
Console.WriteLine("Running the full suite of tests");
GVFSTestConfig.GitRepoTestsValidateWorkTree = DataSources.AllBools;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllMacRunners;
}
}
else
{
GVFSTestConfig.GitRepoTestsValidateWorkTree =
new object[]
{
new object[] { true }
};
if (runner.HasCustomArg("--extra-only"))
{
Console.WriteLine("Running only the tests marked as ExtraCoverage");
includeCategories.Add(Categories.ExtraCoverage);
}
else
{
excludeCategories.Add(Categories.ExtraCoverage);
}
GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
}
if (runner.HasCustomArg("--windows-only"))
{
includeCategories.Add(Categories.WindowsOnly);
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
excludeCategories.Add(Categories.MacTODO.FailsOnBuildAgent);
excludeCategories.Add(Categories.MacTODO.NeedsRenameOldPath);
excludeCategories.Add(Categories.MacTODO.M3);
excludeCategories.Add(Categories.MacTODO.M4);
excludeCategories.Add(Categories.MacTODO.FlakyTest);
excludeCategories.Add(Categories.WindowsOnly);
}
else
{
excludeCategories.Add(Categories.MacOnly);
}
GVFSTestConfig.RepoToClone =
runner.GetCustomArgWithParam("--repo-to-clone")
?? Properties.Settings.Default.RepoToClone;
RunBeforeAnyTests();
Environment.ExitCode = runner.RunTests(includeCategories, excludeCategories);
RunAfterAllTests();
if (Debugger.IsAttached)
{
Console.WriteLine("Tests completed. Press Enter to exit.");
Console.ReadLine();
}
}
private static void RunBeforeAnyTests()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
if (GVFSTestConfig.ReplaceInboxProjFS)
{
ProjFSFilterInstaller.ReplaceInboxProjFS();
}
GVFSServiceProcess.InstallService();
string statusCacheVersionTokenPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData, Environment.SpecialFolderOption.Create),
"GVFS",
"GVFS.Service",
"EnableGitStatusCacheToken.dat");
if (!File.Exists(statusCacheVersionTokenPath))
{
File.WriteAllText(statusCacheVersionTokenPath, string.Empty);
}
}
}
private static void RunAfterAllTests()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
string serviceLogFolder = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
"GVFS",
GVFSServiceProcess.TestServiceName,
"Logs");
Console.WriteLine("GVFS.Service logs at '{0}' attached below.\n\n", serviceLogFolder);
foreach (string filename in TestResultsHelper.GetAllFilesInDirectory(serviceLogFolder))
{
TestResultsHelper.OutputFileContents(filename);
}
GVFSServiceProcess.UninstallService();
}
PrintTestCaseStats.PrintRunTimeStats();
}
}
}