Only run one set of desktop tests (net451 or dnx451).

This commit is contained in:
Pranav K 2016-02-19 17:45:41 -08:00
parent 350f9c4cef
commit a7642bd20d
5 changed files with 95 additions and 135 deletions

View File

@ -17,15 +17,15 @@ IF "%KOREBUILD_DOTNET_VERSION%"=="" (
SET KOREBUILD_DOTNET_VERSION=1.0.0.001496 SET KOREBUILD_DOTNET_VERSION=1.0.0.001496
) )
IF NOT EXIST Sake ( IF NOT EXIST %~dp0Sake (
"%NUGET_PATH%" install Sake -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0 "%NUGET_PATH%" install Sake -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0
) )
IF NOT EXIST xunit.runner.console ( IF NOT EXIST %~dp0xunit.runner.console (
"%NUGET_PATH%" install xunit.runner.console -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0 "%NUGET_PATH%" install xunit.runner.console -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0
) )
IF NOT EXIST xunit.core ( IF NOT EXIST %~dp0xunit.core (
"%NUGET_PATH%" install xunit.core -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0 "%NUGET_PATH%" install xunit.core -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0
) )

View File

@ -2,7 +2,6 @@ use import="Json"
use import="Environment" use import="Environment"
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}' default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
default KOREBUILD_TEST_SKIPMONO='${E("KOREBUILD_TEST_SKIPMONO")}'
@{/* @{/*
@ -12,16 +11,12 @@ dnx-test
projectFile='' projectFile=''
Required. Path to the test project.json to execute Required. Path to the test project.json to execute
framework=''
Required. The TFM to run tests for
*/} */}
@{ @{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
var commands = project.ValueAsJsonObject("commands");
if (commands != null && commands.Keys.Contains("test"))
{
var projectFolder = Path.GetDirectoryName(projectFile); var projectFolder = Path.GetDirectoryName(projectFile);
var projectName = Path.GetFileName(projectFolder); var projectName = Path.GetFileName(projectFolder);
@ -31,25 +26,10 @@ projectFile=''
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)',')); noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
} }
var configs = project.ValueAsJsonObject("frameworks"); var testArgs = noParallelTestProjects.Contains(projectName) || IsLinux ? " -parallel none" : "";
IEnumerable<string> targetFrameworks = configs == null?
new string[0]:
configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
foreach (var framework in targetFrameworks)
{
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
if (framework.StartsWith("dnxcore", StringComparison.OrdinalIgnoreCase)) if (framework.StartsWith("dnxcore", StringComparison.OrdinalIgnoreCase))
{ {
if (IsLinux)
{
// Work around issue with testing in parallel on Mono.
testArgs = " -parallel none";
}
Dnx("test" + testArgs, projectFolder, "default -runtime coreclr"); Dnx("test" + testArgs, projectFolder, "default -runtime coreclr");
} }
} }
}
}

View File

@ -1,4 +1,3 @@
use import="Json"
use import="Environment" use import="Environment"
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}' default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
@ -11,6 +10,9 @@ dotnet-test
projectFile='' projectFile=''
Required. Path to the test project.json to execute Required. Path to the test project.json to execute
framework=''
Required. The TFM to run tests for
configuration='' configuration=''
Optional. The configuration to build in. Defaults to 'Debug'. Optional. The configuration to build in. Defaults to 'Debug'.
*/} */}
@ -18,31 +20,8 @@ configuration=''
default configuration = 'Debug' default configuration = 'Debug'
@{ @{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
// This check is just used to transition from dnx to dotnet
var commands = project.ValueAsJsonObject("commands");
if (commands == null && project.Keys.Contains("testRunner"))
{
var projectFolder = Path.GetDirectoryName(projectFile); var projectFolder = Path.GetDirectoryName(projectFile);
var projectName = Path.GetFileName(projectFolder); var testArgs = "--configuration " + configuration + " --framework " + framework;
var testArgs = "--configuration " + configuration;
var configs = project.ValueAsJsonObject("frameworks");
IEnumerable<string> targetFrameworks = configs == null?
new string[0]:
configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
foreach (var framework in targetFrameworks)
{
if (framework.StartsWith("dnxcore"))
{
Dotnet("test " + testArgs, projectFolder); Dotnet("test " + testArgs, projectFolder);
} }
}
}
}

View File

@ -179,11 +179,44 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
#xunit-test target='test' if='Directory.Exists("test")' #xunit-test target='test' if='Directory.Exists("test")'
@{ @{
var projectFiles = Files.Include("test/**/project.json").Exclude("**/bin/*/app/project.json").ToList(); var projectFiles = Files.Include("test/**/project.json").Exclude("**/bin/*/app/project.json");
projectFiles.ForEach(projectFile => XunitTest(projectFile, testParallel: false, configuration: Configuration)); foreach (var projectFile in projectFiles)
projectFiles.ForEach(projectFile => DotnetTest(projectFile, testParallel: false, configuration: Configuration)); {
projectFiles.ForEach(projectFile => DnxTest(projectFile, testParallel: false)); var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
var configs = project.ValueAsJsonObject("frameworks");
var targetFrameworks = configs == null ? new string[0] : configs.Keys;
var net45TFM = targetFrameworks.FirstOrDefault(t => t.StartsWith("net45", StringComparison.OrdinalIgnoreCase));
var dnx451TFM = targetFrameworks.FirstOrDefault(t => t.Equals("dnx451", StringComparison.OrdinalIgnoreCase));
var dnxCore50TFM = targetFrameworks.FirstOrDefault(t => t.Equals("dnxcore50", StringComparison.OrdinalIgnoreCase));
if (dnxCore50TFM != null)
{
var hasTestCommand = project.Keys.Contains("commands") && project.ValueAsJsonObject("commands").Keys.Contains("test");
if (projectText.Contains("dotnet-test-xunit"))
{
DotnetTest(projectFile, dnxCore50TFM, Configuration);
} }
else if (hasTestCommand)
{
DnxTest(projectFile, dnxCore50TFM, Configuration);
}
}
if (project.Keys.Contains("testRunner"))
{
if (net45TFM != null)
{
XunitTest(projectFile, net45TFM, Configuration);
}
else if (dnx451TFM != null)
{
XunitTest(projectFile, dnx451TFM, Configuration);
}
}
}
}
#make-roslyn-fast #make-roslyn-fast
ngen-roslyn ngen-roslyn
@ -355,22 +388,19 @@ macro name="DotnetBuild" projectFile='string' configuration='string'
macro name="DotnetPack" projectFile='string' dotnetPackOutputDir='string' configuration='string' macro name="DotnetPack" projectFile='string' dotnetPackOutputDir='string' configuration='string'
dotnet-pack dotnet-pack
macro name="DotnetPublish" projectFile='string' outputFolder='string' framework='string'
dotnet-publish
macro name="DotnetPublish" projectFile='string' outputFolder='string' framework='string' configuration='string' macro name="DotnetPublish" projectFile='string' outputFolder='string' framework='string' configuration='string'
dotnet-publish dotnet-publish
macro name="DotnetTest" projectFile='string' testParallel='bool' configuration='string' macro name="DotnetTest" projectFile='string' framework='string' configuration='string'
dotnet-test dotnet-test
macro name="XunitTest" projectFile='string' testParallel='bool' configuration='string' macro name="XunitTest" projectFile='string' framework='string' configuration='string'
xunit-test xunit-test
macro name='Dnx' command='string' dnxDir='string' dnvmUse='string' macro name='Dnx' command='string' dnxDir='string' dnvmUse='string'
dnx dnx
macro name="DnxTest" projectFile='string' testParallel='bool' macro name="DnxTest" projectFile='string' framework='string' configuration='string'
dnx-test dnx-test
macro name="UpdateResx" resxFile='string' macro name="UpdateResx" resxFile='string'

View File

@ -12,19 +12,15 @@ xunit-test
projectFile='' projectFile=''
Required. Path to the test project.json to execute Required. Path to the test project.json to execute
configuration='' framework=''
Optional. The configuration to build in. Defaults to 'Debug'. Required. The TFM to run tests for
*/}
default configuration = 'Debug' configuration=''
Required. The configuration to build in. Defaults to 'Debug'.
*/}
@{ @{
if (!string.Equals(KOREBUILD_TEST_SKIPMONO, "1") && !string.Equals(KOREBUILD_TEST_SKIPMONO, "true")) if (!string.Equals(KOREBUILD_TEST_SKIPMONO, "1") && !string.Equals(KOREBUILD_TEST_SKIPMONO, "true"))
{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
if (project.Keys.Contains("testRunner"))
{ {
var projectFolder = Path.GetDirectoryName(projectFile); var projectFolder = Path.GetDirectoryName(projectFile);
var projectName = Path.GetFileName(projectFolder); var projectName = Path.GetFileName(projectFolder);
@ -36,19 +32,9 @@ default configuration = 'Debug'
} }
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : ""; var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
var configs = project.ValueAsJsonObject("frameworks");
var targetFrameworks = configs == null
? new string[0]
: configs.Keys
.Where(k => k.StartsWith("dnx4", StringComparison.OrdinalIgnoreCase)
|| k.StartsWith("net4", StringComparison.OrdinalIgnoreCase));
var runnerFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.runner.console", "tools")); var runnerFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.runner.console", "tools"));
var xunitCoreFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.core", "build", "_desktop")); var xunitCoreFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.core", "build", "_desktop"));
foreach (var framework in targetFrameworks)
{
if (IsLinux) if (IsLinux)
{ {
// Work around issue with testing in parallel on Mono. // Work around issue with testing in parallel on Mono.
@ -59,27 +45,12 @@ default configuration = 'Debug'
DotnetPublish(projectFile, publishFolder, framework, configuration); DotnetPublish(projectFile, publishFolder, framework, configuration);
var runnerExe = "xunit.console.exe"; var runnerExe = "xunit.console.exe";
string runnerFullPath;
// Copy xunit.execution.desktop. This is required in order to load the binding
// redirects for dlls. See this thread for more details:
// https://github.com/xunit/xunit/issues/732
// Furthermore, xunit.console.exe must be launched in the same folder as the test dll
if (framework.StartsWith("dnx", StringComparison.OrdinalIgnoreCase))
{
Copy(runnerFolder, publishFolder, "*.*", true); Copy(runnerFolder, publishFolder, "*.*", true);
Copy(xunitCoreFolder, publishFolder, "*.*", true); Copy(xunitCoreFolder, publishFolder, "*.*", true);
runnerFullPath = Path.GetFullPath(Path.Combine(publishFolder, runnerExe)); var runnerFullPath = Path.GetFullPath(Path.Combine(publishFolder, runnerExe));
}
else
{
runnerFullPath = Path.Combine(runnerFolder, runnerExe);
}
var targetTestDll = projectName + ".dll"; var targetTestDll = projectName + ".dll";
ExecClr(runnerFullPath, targetTestDll + " " + testArgs, publishFolder); ExecClr(runnerFullPath, targetTestDll + " " + testArgs, publishFolder);
} }
} }
}
}