57 lines
2.0 KiB
Plaintext
57 lines
2.0 KiB
Plaintext
use import="Json"
|
|
use import="Environment"
|
|
|
|
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
|
|
default KOREBUILD_TEST_SKIPMONO='${E("KOREBUILD_TEST_SKIPMONO")}'
|
|
|
|
@{/*
|
|
|
|
xunit-test
|
|
Run unit tests in your project.
|
|
|
|
projectFile=''
|
|
Required. Path to the test project.json to execute
|
|
|
|
framework=''
|
|
Required. The TFM to run tests for
|
|
|
|
configuration=''
|
|
Required. The configuration to build in. Defaults to 'Debug'.
|
|
*/}
|
|
|
|
@{
|
|
if (!string.Equals(KOREBUILD_TEST_SKIPMONO, "1") && !string.Equals(KOREBUILD_TEST_SKIPMONO, "true"))
|
|
{
|
|
var projectFolder = Path.GetDirectoryName(projectFile);
|
|
var projectName = Path.GetFileName(projectFolder);
|
|
|
|
var noParallelTestProjects = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
if (!string.IsNullOrEmpty(NO_PARALLEL_TEST_PROJECTS))
|
|
{
|
|
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
|
|
}
|
|
|
|
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
|
|
var runnerFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.runner.console", "tools"));
|
|
var xunitCoreFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.core", "build", "_desktop"));
|
|
|
|
if (IsLinux)
|
|
{
|
|
// Work around issue with testing in parallel on Mono.
|
|
testArgs = " -parallel none";
|
|
}
|
|
|
|
var publishFolder = Path.Combine(projectFolder, "obj", "testPublish-" + framework);
|
|
DotnetPublish(projectFile, publishFolder, framework, configuration);
|
|
|
|
var runnerExe = "xunit.console.exe";
|
|
Copy(runnerFolder, publishFolder, "*.*", true);
|
|
Copy(xunitCoreFolder, publishFolder, "*.*", true);
|
|
var runnerFullPath = Path.GetFullPath(Path.Combine(publishFolder, runnerExe));
|
|
|
|
var targetTestDll = projectName + ".dll";
|
|
|
|
ExecClr(runnerFullPath, targetTestDll + " " + testArgs, publishFolder);
|
|
}
|
|
}
|