From cc82704b5b39124cd0a61a500e1d9e0be0c96c5c Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 15 Oct 2015 10:06:01 -0700 Subject: [PATCH] Updating TestRunner to sort unit test assemblies by size. --- netci.groovy | 2 +- src/Tools/Source/RunTests/Program.cs | 26 ++++++------------------- src/Tools/Source/RunTests/TestRunner.cs | 12 +++--------- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/netci.groovy b/netci.groovy index 3828c78cdfb..4db5b48c4b6 100644 --- a/netci.groovy +++ b/netci.groovy @@ -71,7 +71,7 @@ static void addUnitPublisher(def myJob) { 'xunit'('plugin': 'xunit@1.97') { 'types' { 'XUnitDotNetTestType' { - 'pattern'('**/*TestResults.xml') + 'pattern'('**/xUnitResults/*.xml') 'skipNoTestFiles'(false) 'failIfNotNew'(true) 'deleteOutputFiles'(true) diff --git a/src/Tools/Source/RunTests/Program.cs b/src/Tools/Source/RunTests/Program.cs index 8436acd86e0..b208734ac38 100644 --- a/src/Tools/Source/RunTests/Program.cs +++ b/src/Tools/Source/RunTests/Program.cs @@ -48,8 +48,8 @@ internal static int Main(string[] args) var testRunner = new TestRunner(xunit, useHtml); var start = DateTime.Now; Console.WriteLine("Running {0} tests", list.Count); - OrderAssemblyList(list); - var result = testRunner.RunAllAsync(list, cts.Token).Result; + var orderedList = OrderAssemblyList(list); + var result = testRunner.RunAllAsync(orderedList, cts.Token).Result; var span = DateTime.Now - start; if (!result) { @@ -90,25 +90,11 @@ private static void ParseArgs(string[] args, ref int index, ref bool test64, ref } /// - /// Order the assembly list so the known slower test begin running earlier. This - /// should really be dynamically calculated and not hard coded like this. + /// Order the assembly list so that the largest assemblies come first. This + /// is not ideal as the largest assembly does not necessarily take the most time. /// /// - private static void OrderAssemblyList(List list) - { - 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++; - } - } + private static IOrderedEnumerable OrderAssemblyList(List list) => + list.OrderByDescending((assemblyName) => new FileInfo(assemblyName).Length); } } diff --git a/src/Tools/Source/RunTests/TestRunner.cs b/src/Tools/Source/RunTests/TestRunner.cs index 74be27c0d4a..77094591792 100644 --- a/src/Tools/Source/RunTests/TestRunner.cs +++ b/src/Tools/Source/RunTests/TestRunner.cs @@ -115,19 +115,13 @@ private void Print(List testResults) 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 RunTest(string assemblyPath, CancellationToken cancellationToken) { try { var assemblyName = Path.GetFileName(assemblyPath); - var extension = _useHtml ? ".TestResults.html" : ".TestResults.xml"; - var resultsPath = Path.Combine(Path.GetDirectoryName(assemblyPath), Path.ChangeExtension(assemblyName, extension)); + var extension = _useHtml ? "html" : "xml"; + var resultsPath = Path.Combine(Path.GetDirectoryName(assemblyPath), "xUnitResults", $"{assemblyName}.{extension}"); DeleteFile(resultsPath); var builder = new StringBuilder(); @@ -138,7 +132,7 @@ private async Task RunTest(string assemblyPath, CancellationToken ca var errorOutput = new StringBuilder(); 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( xunitPath, builder.ToString(), -- GitLab