Enable running tests using dotnet xunit test runner
This commit is contained in:
parent
33ddbf8f4c
commit
c0ed67e96f
|
|
@ -17,7 +17,10 @@ projectFile=''
|
||||||
var projectText = File.ReadAllText(projectFile);
|
var projectText = File.ReadAllText(projectFile);
|
||||||
var project = (JsonObject)Json.Deserialize(projectText);
|
var project = (JsonObject)Json.Deserialize(projectText);
|
||||||
|
|
||||||
if (project.Keys.Contains("testRunner"))
|
// 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 projectName = Path.GetFileName(projectFolder);
|
||||||
|
|
@ -27,25 +30,21 @@ projectFile=''
|
||||||
{
|
{
|
||||||
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
|
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
|
||||||
}
|
}
|
||||||
|
|
||||||
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
|
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
|
||||||
|
|
||||||
var configs = project.ValueAsJsonObject("frameworks");
|
var configs = project.ValueAsJsonObject("frameworks");
|
||||||
IEnumerable<string> targetFrameworks = configs == null?
|
IEnumerable<string> targetFrameworks = configs == null?
|
||||||
new string[0]:
|
new string[0]:
|
||||||
configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
|
configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
foreach (var framework in targetFrameworks)
|
foreach (var framework in targetFrameworks)
|
||||||
{
|
{
|
||||||
if (framework.StartsWith("dnxcore"))
|
if (framework.StartsWith("dnxcore"))
|
||||||
{
|
{
|
||||||
var publishFolder = Path.Combine(projectFolder, ".testPublish", framework);
|
Dotnet("test " + testArgs, projectFolder);
|
||||||
DotnetPublish(projectFile, publishFolder, framework);
|
|
||||||
|
|
||||||
var runnerExe = Path.Combine(publishFolder, "dotnet-test-xunit.exe");
|
|
||||||
var targetTestDll = Path.Combine(publishFolder, projectName + ".dll");
|
|
||||||
Exec(runnerExe, targetTestDll + " " + testArgs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,13 +96,13 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
||||||
@{
|
@{
|
||||||
var projectFiles = Files.Include("src/**/project.json").ToList();
|
var projectFiles = Files.Include("src/**/project.json").ToList();
|
||||||
projectFiles.ForEach(projectFile => DotnetPack(projectFile, BUILD_DIR, Configuration));
|
projectFiles.ForEach(projectFile => DotnetPack(projectFile, BUILD_DIR, Configuration));
|
||||||
|
|
||||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
||||||
{
|
{
|
||||||
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
|
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#build-test target='compile' if='Directory.Exists("test") && !BuildSrcOnly'
|
#build-test target='compile' if='Directory.Exists("test") && !BuildSrcOnly'
|
||||||
@{
|
@{
|
||||||
var projectFiles = Files.Include("test/**/project.json")
|
var projectFiles = Files.Include("test/**/project.json")
|
||||||
|
|
@ -178,7 +178,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
||||||
@{
|
@{
|
||||||
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").ToList();
|
||||||
projectFiles.ForEach(projectFile => XunitTest(projectFile, testParallel: false));
|
projectFiles.ForEach(projectFile => XunitTest(projectFile, testParallel: false));
|
||||||
//projectFiles.ForEach(projectFile => DotnetTest(projectFile, testParallel: false));
|
projectFiles.ForEach(projectFile => DotnetTest(projectFile, testParallel: false));
|
||||||
projectFiles.ForEach(projectFile => DnxTest(projectFile, testParallel: false));
|
projectFiles.ForEach(projectFile => DnxTest(projectFile, testParallel: false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
|
||||||
AddToE("KOREBUILD_NPM_INSTALL_OPTIONS", "--quiet");
|
AddToE("KOREBUILD_NPM_INSTALL_OPTIONS", "--quiet");
|
||||||
Quiet = true;
|
Quiet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#--parallel
|
#--parallel
|
||||||
@{
|
@{
|
||||||
Log.Warn("The --parallel flag is no longer supported. It will be ignored.");
|
Log.Warn("The --parallel flag is no longer supported. It will be ignored.");
|
||||||
|
|
@ -307,8 +307,8 @@ functions @{
|
||||||
{
|
{
|
||||||
get { return E("KOREBUILD_VERIFY_NUPKGS") == "1"; }
|
get { return E("KOREBUILD_VERIFY_NUPKGS") == "1"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildSrcOnly
|
bool BuildSrcOnly
|
||||||
{
|
{
|
||||||
get { return E("KOREBUILD_BUILD_SRC_ONLY") == "1"; }
|
get { return E("KOREBUILD_BUILD_SRC_ONLY") == "1"; }
|
||||||
}
|
}
|
||||||
|
|
@ -322,7 +322,7 @@ macro name='Exec' program='string' commandline='string' workingdir='string'
|
||||||
|
|
||||||
macro name='ExecClr' program='string' commandline='string'
|
macro name='ExecClr' program='string' commandline='string'
|
||||||
exec-clr
|
exec-clr
|
||||||
|
|
||||||
macro name='ExecClr' program='string' commandline='string' workingdir='string'
|
macro name='ExecClr' program='string' commandline='string' workingdir='string'
|
||||||
exec-clr
|
exec-clr
|
||||||
|
|
||||||
|
|
@ -339,7 +339,7 @@ macro name='Dotnet' command='string'
|
||||||
dotnet
|
dotnet
|
||||||
|
|
||||||
macro name='Dotnet' command='string' dotnetDir='string'
|
macro name='Dotnet' command='string' dotnetDir='string'
|
||||||
dotnet
|
dotnet
|
||||||
|
|
||||||
macro name="DotnetBuild" projectFile='string' configuration='string'
|
macro name="DotnetBuild" projectFile='string' configuration='string'
|
||||||
dotnet-build
|
dotnet-build
|
||||||
|
|
@ -347,7 +347,7 @@ 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'
|
macro name="DotnetPublish" projectFile='string' outputFolder='string' framework='string'
|
||||||
dotnet-publish
|
dotnet-publish
|
||||||
|
|
||||||
macro name="DotnetTest" projectFile='string' testParallel='bool'
|
macro name="DotnetTest" projectFile='string' testParallel='bool'
|
||||||
|
|
@ -355,10 +355,10 @@ macro name="DotnetTest" projectFile='string' testParallel='bool'
|
||||||
|
|
||||||
macro name="XunitTest" projectFile='string' testParallel='bool'
|
macro name="XunitTest" projectFile='string' testParallel='bool'
|
||||||
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' testParallel='bool'
|
||||||
dnx-test
|
dnx-test
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue