Execute tests in parallel if --parallel is specified

This commit is contained in:
Pranav K 2016-03-07 21:15:20 -08:00
Родитель e6b43938a8
Коммит b62e25459a
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -207,8 +207,13 @@ default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
#xunit-test target='test' if='Directory.Exists("test")'
@{
var projectFiles = Files.Include("test/*/project.json");
foreach (var projectFile in projectFiles)
var projectFiles = Files.Include("test/*/project.json").ToArray();
var parallelOptions = new ParallelOptions
{
MaxDegreeOfParallelism = ExecuteParallel ? 8 : 1
};
Parallel.ForEach(projectFiles, parallelOptions, (projectFile, _) =>
{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
@ -235,7 +240,7 @@ default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
XunitTest(projectFile, dnx451TFM, Configuration);
}
}
}
});
}
@ -276,9 +281,7 @@ default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
}
#--parallel
@{
Log.Warn("The --parallel flag is no longer supported. It will be ignored.");
}
@{ ExecuteParallel = true; }
#--test-dnxcore
@{
@ -288,6 +291,7 @@ default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
functions @{
private static bool Quiet { get; set; }
private static bool NoRestore { get; set; }
private static bool ExecuteParallel { get; set; }
string E(string key) { return Environment.GetEnvironmentVariable(key); }
void E(string key, string value) { Environment.SetEnvironmentVariable(key, value); }