Skip to content

Commit

Permalink
Merge pull request #44055 from sharwell/sequential-testing
Browse files Browse the repository at this point in the history
Support sequential testing
  • Loading branch information
sharwell authored May 15, 2020
2 parents 60bc2ff + 63f7215 commit d1a0151
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ param (
[switch][Alias('test')]$testDesktop,
[switch]$testCoreClr,
[switch]$testIOperation,
[switch]$sequential,

[parameter(ValueFromRemainingArguments=$true)][string[]]$properties)

Expand Down Expand Up @@ -436,6 +437,10 @@ function TestUsingOptimizedRunner() {
$args += " -test64"
}

if ($sequential) {
$args += " -sequential"
}

foreach ($dll in $dlls) {
$args += " $dll"
}
Expand Down
12 changes: 3 additions & 9 deletions src/Tools/Source/RunTests/AssemblyScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,13 @@ internal AssemblyScheduler(Options options, int methodLimit = DefaultMethodLimit
_methodLimit = methodLimit;
}

internal IEnumerable<AssemblyInfo> Schedule(IEnumerable<string> assemblyPaths)
public IEnumerable<AssemblyInfo> Schedule(string assemblyPath, bool force = false)
{
var list = new List<AssemblyInfo>();
foreach (var assemblyPath in assemblyPaths)
if (_options.Sequential)
{
list.AddRange(Schedule(assemblyPath));
return new[] { CreateAssemblyInfo(assemblyPath) };
}

return list;
}

public IEnumerable<AssemblyInfo> Schedule(string assemblyPath, bool force = false)
{
var typeInfoList = GetTypeInfoList(assemblyPath);
var assemblyInfoList = new List<AssemblyInfo>();
var partitionList = new List<Partition>();
Expand Down
10 changes: 10 additions & 0 deletions src/Tools/Source/RunTests/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ internal class Options
/// </summary>
public bool UseProcDump { get; set; }

/// <summary>
/// Disable partitioning and parallelization across test assemblies.
/// </summary>
public bool Sequential { get; set; }

/// <summary>
/// The directory which contains procdump.exe.
/// </summary>
Expand Down Expand Up @@ -214,6 +219,11 @@ bool isOption(string argument, string optionName, out string value)
opt.UseProcDump = false;
index++;
}
else if (comparer.Equals(current, "-sequential"))
{
opt.Sequential = true;
index++;
}
else
{
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Source/RunTests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal async Task<RunAllResult> RunAllAsync(IEnumerable<AssemblyInfo> assembly
// Use 1.5 times the number of processors for unit tests, but only 1 processor for the open integration tests
// since they perform actual UI operations (such as mouse clicks and sending keystrokes) and we don't want two
// tests to conflict with one-another.
var max = (_options.TestVsi) ? 1 : (int)(Environment.ProcessorCount * 1.5);
var max = (_options.TestVsi || _options.Sequential) ? 1 : (int)(Environment.ProcessorCount * 1.5);
var cacheCount = 0;
var waiting = new Stack<AssemblyInfo>(assemblyInfoList);
var running = new List<Task<TestResult>>();
Expand Down

0 comments on commit d1a0151

Please sign in to comment.