提交 cc82704b 编写于 作者: T Tanner Gooding

Updating TestRunner to sort unit test assemblies by size.

上级 972e7e1b
...@@ -71,7 +71,7 @@ static void addUnitPublisher(def myJob) { ...@@ -71,7 +71,7 @@ static void addUnitPublisher(def myJob) {
'xunit'('plugin': 'xunit@1.97') { 'xunit'('plugin': 'xunit@1.97') {
'types' { 'types' {
'XUnitDotNetTestType' { 'XUnitDotNetTestType' {
'pattern'('**/*TestResults.xml') 'pattern'('**/xUnitResults/*.xml')
'skipNoTestFiles'(false) 'skipNoTestFiles'(false)
'failIfNotNew'(true) 'failIfNotNew'(true)
'deleteOutputFiles'(true) 'deleteOutputFiles'(true)
......
...@@ -48,8 +48,8 @@ internal static int Main(string[] args) ...@@ -48,8 +48,8 @@ internal static int Main(string[] args)
var testRunner = new TestRunner(xunit, useHtml); var testRunner = new TestRunner(xunit, useHtml);
var start = DateTime.Now; var start = DateTime.Now;
Console.WriteLine("Running {0} tests", list.Count); Console.WriteLine("Running {0} tests", list.Count);
OrderAssemblyList(list); var orderedList = OrderAssemblyList(list);
var result = testRunner.RunAllAsync(list, cts.Token).Result; var result = testRunner.RunAllAsync(orderedList, cts.Token).Result;
var span = DateTime.Now - start; var span = DateTime.Now - start;
if (!result) if (!result)
{ {
...@@ -90,25 +90,11 @@ private static void ParseArgs(string[] args, ref int index, ref bool test64, ref ...@@ -90,25 +90,11 @@ private static void ParseArgs(string[] args, ref int index, ref bool test64, ref
} }
/// <summary> /// <summary>
/// Order the assembly list so the known slower test begin running earlier. This /// Order the assembly list so that the largest assemblies come first. This
/// should really be dynamically calculated and not hard coded like this. /// is not ideal as the largest assembly does not necessarily take the most time.
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="list"></param>
private static void OrderAssemblyList(List<string> list) private static IOrderedEnumerable<string> OrderAssemblyList(List<string> list) =>
{ list.OrderByDescending((assemblyName) => new FileInfo(assemblyName).Length);
var regex = new Regex(@"Roslyn.Services.Editor.(\w+).UnitTests", RegexOptions.IgnoreCase);
var i = 1;
while (i < list.Count)
{
var cur = list[i];
if (regex.IsMatch(cur))
{
list.RemoveAt(i);
list.Insert(0, cur);
}
i++;
}
}
} }
} }
...@@ -115,19 +115,13 @@ private void Print(List<TestResult> testResults) ...@@ -115,19 +115,13 @@ private void Print(List<TestResult> testResults)
Console.WriteLine("================"); Console.WriteLine("================");
} }
private static readonly string[] UpgradedTests = new string[] {
"Microsoft.DiaSymReader.PortablePdb.UnitTests.dll",
"Microsoft.CodeAnalysis.Scripting.VisualBasic.UnitTests.dll",
"Microsoft.CodeAnalysis.Scripting.CSharp.UnitTests.dll"
};
private async Task<TestResult> RunTest(string assemblyPath, CancellationToken cancellationToken) private async Task<TestResult> RunTest(string assemblyPath, CancellationToken cancellationToken)
{ {
try try
{ {
var assemblyName = Path.GetFileName(assemblyPath); var assemblyName = Path.GetFileName(assemblyPath);
var extension = _useHtml ? ".TestResults.html" : ".TestResults.xml"; var extension = _useHtml ? "html" : "xml";
var resultsPath = Path.Combine(Path.GetDirectoryName(assemblyPath), Path.ChangeExtension(assemblyName, extension)); var resultsPath = Path.Combine(Path.GetDirectoryName(assemblyPath), "xUnitResults", $"{assemblyName}.{extension}");
DeleteFile(resultsPath); DeleteFile(resultsPath);
var builder = new StringBuilder(); var builder = new StringBuilder();
...@@ -138,7 +132,7 @@ private async Task<TestResult> RunTest(string assemblyPath, CancellationToken ca ...@@ -138,7 +132,7 @@ private async Task<TestResult> RunTest(string assemblyPath, CancellationToken ca
var errorOutput = new StringBuilder(); var errorOutput = new StringBuilder();
var start = DateTime.UtcNow; var start = DateTime.UtcNow;
var xunitPath = UpgradedTests.Contains(assemblyName) ? Path.Combine($"{Path.GetDirectoryName(_xunitConsolePath)}", @"..\..\..\xunit.runner.console\2.1.0\tools", $"{Path.GetFileName(_xunitConsolePath)}") : _xunitConsolePath; var xunitPath = _xunitConsolePath;
var processOutput = await ProcessRunner.RunProcessAsync( var processOutput = await ProcessRunner.RunProcessAsync(
xunitPath, xunitPath,
builder.ToString(), builder.ToString(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册