Remove dnx and make CLR tests use the xunit runner

This commit is contained in:
Victor Hurdugaci 2015-12-17 12:15:42 -08:00
parent 63c47a9c6d
commit ae85d226be
16 changed files with 126 additions and 3268 deletions

View File

@ -1,69 +0,0 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Make sh files under the build directory always have LF as line endings
###############################################################################
build/*.sh eol=lf
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -25,4 +25,20 @@ functions
return "t" + DateTime.UtcNow.ToString("yyMMddHHmmss");
}
}
string DotBuildFolderPath
{
get
{
return Environment.GetEnvironmentVariable("BUILD_FOLDER");
}
}
string KoreBuildFolderPath
{
get
{
return Environment.GetEnvironmentVariable("KOREBUILD_FOLDER");
}
}
}

View File

@ -14,6 +14,10 @@ IF NOT EXIST Sake (
"%NUGET_PATH%" install Sake -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0
)
IF NOT EXIST xunit.runner.console (
"%NUGET_PATH%" install xunit.runner.console -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0
)
SET DOTNET_LOCAL_INSTALL_FOLDER=%LOCALAPPDATA%\Microsoft\dotnet\cli\bin
CALL %~dp0dotnet-install.cmd
@ -21,18 +25,6 @@ ECHO Adding %DOTNET_LOCAL_INSTALL_FOLDER% to PATH
SET PATH=%DOTNET_LOCAL_INSTALL_FOLDER%;%PATH%
SET DOTNET_HOME=%DOTNET_LOCAL_INSTALL_FOLDER%
REM ==== Temporary because we need 'dnu packages add' ====
IF "%BUILDCMD_DNX_VERSION%"=="" (
SET BUILDCMD_DNX_VERSION=latest
)
IF "%SKIP_DNX_INSTALL%"=="" (
CALL %KOREBUILD_FOLDER%\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default
CALL %KOREBUILD_FOLDER%\build\dnvm install default -runtime CLR -arch x86 -alias default
) ELSE (
CALL %KOREBUILD_FOLDER%\build\dnvm use default -runtime CLR -arch x86
)
REM ============================
SET MAKEFILE_PATH=makefile.shade
IF NOT EXIST %MAKEFILE_PATH% (
SET MAKEFILE_PATH=%KOREBUILD_FOLDER%\build\makefile.shade

View File

@ -11,16 +11,20 @@ if [ -z "$nugetPath" ]; then
fi
sakeFolder=$koreBuildFolder/build/Sake
if test ! -d $sakeFolder; then
mono $nugetPath install Sake -ExcludeVersion -o $koreBuildFolder/build -nocache -pre
fi
if test ! -d $koreBuildFolder/build/xunit.runner.console; then
mono $nugetPath install xunit.runner.console -ExcludeVersion -o $koreBuildFolder/build -nocache -pre
fi
# Need to set this variable because by default the install script
# requires sudo
export DOTNET_INSTALL_DIR=~/.dotnet
export PATH=$DOTNET_INSTALL_DIR/bin:$PATH
export PATH=~/.dotnet/bin:$PATH
export DOTNET_HOME=DOTNET_INSTALL_DIR
export KOREBUILD_FOLDER=$koreBuildFolder
source $koreBuildFolder/build/dotnet-install.sh
makefilePath=makefile.shade
@ -28,18 +32,6 @@ if test ! -f $makefilePath; then
makefilePath=$koreBuildFolder/build/makefile.shade
fi
# ==== Temporary because we need 'dnu packages add' ====
if ! type dnvm > /dev/null 2>&1; then
source $koreBuildFolder/build/dnvm.sh
fi
if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
dnvm install latest -runtime coreclr -alias default
dnvm install default -runtime mono -alias default
else
dnvm use default -runtime mono
fi
# ============
# Probe for Mono Reference assemblies
if test -z "$DOTNET_REFERENCE_ASSEMBLIES_PATH"; then
if test $(uname) == Darwin && test -d "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks"; then
@ -53,5 +45,5 @@ fi
echo "Using Reference Assemblies from: $DOTNET_REFERENCE_ASSEMBLIES_PATH"
mono $koreBuildFolder/build/Sake/tools/Sake.exe -I $koreBuildFolder/build -f $makefilePath "$@"
mono $sakeFolder/tools/Sake.exe -I $koreBuildFolder/build -f $makefilePath "$@"

View File

@ -1,85 +0,0 @@
use import="Json"
use import="Environment"
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
default KOREBUILD_TEST_DNXCORE='${E("KOREBUILD_TEST_DNXCORE")}'
default KOREBUILD_TEST_SKIPMONO='${E("KOREBUILD_TEST_SKIPMONO")}'
@{/*
// ====== This file shall be removed eventually ====
dnx-test
Run unit tests in your project.
projectFile=''
Required. Path to the test project.json to execute
*/}
@{
Console.WriteLine("Project file: " + projectFile);
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 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 configs = project.ValueAsJsonObject("frameworks");
IEnumerable<string> targetFrameworks;
if (configs == null)
{
// Assume dnx451 only if none specified
targetFrameworks = new[] { "dnx451" };
}
else
{
targetFrameworks = configs.Keys;
}
// Currently only dnx* targets are supported. See aspnet/Universe#53
targetFrameworks = targetFrameworks.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 (IsLinux)
{
// Work around issue with testing in parallel on Mono.
testArgs = " -parallel none";
}
if (!IsLinux ||
(!string.Equals(KOREBUILD_TEST_SKIPMONO, "1") &&
!string.Equals(KOREBUILD_TEST_SKIPMONO, "true")))
{
Dnx("test" + testArgs, projectFolder);
}
}
/*
Core CLR tests run with the new runner
else if (!IsLinux ||
string.Equals(KOREBUILD_TEST_DNXCORE, "1") ||
string.Equals(KOREBUILD_TEST_DNXCORE, "true"))
{
Dnx("test" + testArgs, projectFolder, "default -runtime coreclr");
}
*/
}
}
}

View File

@ -1,30 +0,0 @@
@{/*
// ====== This file shall be removed eventually ====
k
Run dnx commands in your project. Executes `dnx` command.
command=''
The `dnx` subcommand to execute.
dnxDir=''
Optional. The directory in which to execute the `dnx` command.
dnvmUse=''
Optional. The DNX framework to use. Suitable for a `dnvm run` or `dnvm use` command.
*/}
default currentDir = '${Directory.GetCurrentDirectory()}'
default dnxDir = '${ currentDir }'
default dnvmUse=''
var dnvmPath = '${ Path.Combine(Directory.GetCurrentDirectory(), ".build", "KoreBuild-dotnet", "build", "dnvm") }'
exec program='cmd' commandline='/C dnx ${command}' workingdir='${dnxDir}' if='!IsLinux && string.IsNullOrEmpty(dnvmUse)'
var cmdCommand = '/S /C ""${dnvmPath}.cmd" use ${dnvmUse} && dnx ${command}"'
exec program='cmd' commandline='${ cmdCommand }' workingdir='${dnxDir}' if='!IsLinux && !string.IsNullOrEmpty(dnvmUse)'
exec program='dnx' commandline='${command}' workingdir='${dnxDir}' if='IsLinux && string.IsNullOrEmpty(dnvmUse)'
var envCommand = 'bash -c "source \"${dnvmPath}.sh\" && dnvm use ${dnvmUse} && dnx ${command}"'
exec program='/usr/bin/env' commandline='${ envCommand }' workingdir='${dnxDir}' if='IsLinux && !string.IsNullOrEmpty(dnvmUse)'

View File

@ -11,6 +11,9 @@ outputFolder=''
configuration=''
Optional. The configuration to build in. Defaults to 'Debug'.
framework=''
Optional. The framework to publish
*/}
default configuration = 'Debug'
@ -20,10 +23,12 @@ default configuration = 'Debug'
var projectName=Path.GetFileName(projectFolder);
var projectBin=Path.Combine(projectFolder, "bin", configuration);
var outputArg = string.IsNullOrEmpty(outputFolder)? "": "-o " + outputFolder;
var outputArg = string.IsNullOrEmpty(outputFolder)? "": "--output " + outputFolder;
var frameworkArg = string.IsNullOrEmpty(framework)? "": "--framework " + framework;
DeleteFolder(projectBin);
var dotnetArgs=string.Format("publish --configuration {0} {1} {2}", configuration, outputArg, projectFolder);
var dotnetArgs=string.Format("publish --configuration {0} {1} {2} {3}", configuration, frameworkArg, outputArg, projectFolder);
Dotnet(dotnetArgs);
}
}

View File

@ -2,8 +2,6 @@ use import="Json"
use import="Environment"
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
default KOREBUILD_TEST_DNXCORE='${E("KOREBUILD_TEST_DNXCORE")}'
default KOREBUILD_TEST_SKIPMONO='${E("KOREBUILD_TEST_SKIPMONO")}'
@{/*
@ -29,28 +27,20 @@ projectFile=''
{
noParallelTestProjects.UnionWith(NO_PARALLEL_TEST_PROJECTS.Split((char)','));
}
var testArgs = noParallelTestProjects.Contains(projectName) ? " -parallel none" : "";
var configs = project.ValueAsJsonObject("frameworks");
IEnumerable<string> targetFrameworks;
if (configs == null)
{
// Assume dnx451 only if none specified
targetFrameworks = new[] { "dnx451" };
}
else
{
targetFrameworks = configs.Keys;
}
// Currently only dnx* targets are supported. See aspnet/Universe#53
targetFrameworks = targetFrameworks.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
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"))
{
var publishFolder = Path.Combine(projectFolder, ".testPublish", framework);
DotnetPublish(projectFile, publishFolder);
var publishFolder = Path.Combine(projectFolder, ".testPublish", framework);
DotnetPublish(projectFile, publishFolder, framework);
var runnerExe = Path.Combine(publishFolder, "dotnet-test-xunit.exe");
var targetTestDll = Path.Combine(publishFolder, projectName + ".dll");
@ -58,4 +48,4 @@ projectFile=''
}
}
}
}
}

View File

@ -12,4 +12,4 @@ dotnetDir=''
default currentDir = '${Directory.GetCurrentDirectory()}'
default dotnetDir = '${ currentDir }'
exec program='dotnet' commandline='${command}' workingdir='${dotnetDir}'
exec program='dotnet' commandline='${command}' workingdir='${dotnetDir}'

View File

@ -170,12 +170,12 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
var projectFiles = Files.Include("test/**/project.json").Exclude("**/bin/*/app/project.json").ToList();
if (ShouldRunInParallel)
{
Parallel.ForEach(projectFiles, projectFile => DnxTest(projectFile, testParallel: true));
Parallel.ForEach(projectFiles, projectFile => XunitTest(projectFile, testParallel: true));
Parallel.ForEach(projectFiles, projectFile => DotnetTest(projectFile, testParallel: true));
}
else
{
projectFiles.ForEach(projectFile => DnxTest(projectFile, testParallel: false));
projectFiles.ForEach(projectFile => XunitTest(projectFile, testParallel: false));
projectFiles.ForEach(projectFile => DotnetTest(projectFile, testParallel: false));
}
}
@ -196,28 +196,6 @@ default NUGET_FEED = 'https://api.nuget.org/v3/index.json'
#make-roslyn-fast
ngen-roslyn
#resx
@{
var cultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures | CultureTypes.InstalledWin32Cultures | CultureTypes.SpecificCultures);
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.resx", SearchOption.AllDirectories))
{
var splitFileName = Path.GetFileNameWithoutExtension(file).Split(new string[] { "." }, StringSplitOptions.None);
if (splitFileName.Length > 1)
{
var localeString = splitFileName.Last();
if (!cultures.Any(c => localeString.Equals(c.Name)))
{
UpdateResx(file);
}
}
else
{
UpdateResx(file);
}
}
}
#--quiet
@{
AddToE("KOREBUILD_BOWER_INSTALL_OPTIONS", "--quiet");
@ -331,45 +309,42 @@ functions @{
macro name='Exec' program='string' commandline='string'
exec
macro name='Exec' program='string' commandline='string' workingdir='string'
exec
macro name='ExecClr' program='string' commandline='string'
exec-clr
macro name='ExecClr' program='string' commandline='string' workingdir='string'
exec-clr
macro name="DeleteFolder" delete='string'
directory
macro name="Copy" sourceDir='string' outputDir='string' include='string' overwrite='bool'
copy
macro name="CopyFolder" sourceDir='string' outputDir='string' overwrite='bool'
copy
macro name='Dotnet' command='string'
dotnet
macro name='Dotnet' command='string' dotnetDir='string'
dotnet
dotnet
macro name="UpdateResx" resxFile='string'
k-generate-resx
macro name="DotnetTest" projectFile='string' testParallel='bool'
dotnet-test
macro name="DotnetCompile" projectFile='string' configuration='string'
dotnet-compile
macro name="DotnetPack" projectFile='string' dotnetPackOutputDir='string' configuration='string'
dotnet-pack
macro name="DotnetPublish" projectFile='string' outputFolder='string'
macro name="DotnetPublish" projectFile='string' outputFolder='string' framework='string'
dotnet-publish
macro name="DeleteFolder" delete='string'
directory
macro name="DotnetTest" projectFile='string' testParallel='bool'
dotnet-test
macro name="CopyFolder" sourceDir='string' outputDir='string' overwrite='bool'
copy
@{
// === EVERYTHING BELOW THIS LINE IS TEMPORARY ===
}
macro name='Dnx' command='string'
dnx
macro name='Dnx' command='string' dnxDir='string'
dnx
macro name='Dnx' command='string' dnxDir='string' dnvmUse='string'
dnx
macro name="DnxTest" projectFile='string' testParallel='bool'
dnx-test
macro name="XunitTest" projectFile='string' testParallel='bool'
xunit-test

View File

@ -51,6 +51,3 @@ set nugetArgs='${nugetArgs} ${extra}' if='!string.IsNullOrEmpty(extra)'
}
});
}
macro name='ExecClr' program='string' commandline='string'
exec-clr

View File

@ -0,0 +1,53 @@
use import="Json"
use import="Environment"
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
@{/*
xunit-test
Run unit tests in your project.
projectFile=''
Required. Path to the test project.json to execute
*/}
@{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
if (project.Keys.Contains("testRunner"))
{
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 configs = project.ValueAsJsonObject("frameworks");
IEnumerable<string> targetFrameworks = configs == null?
new string[0]:
configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
var runnerFolder = Path.GetFullPath(Path.Combine(KoreBuildFolderPath, "build", "xunit.runner.console", "tools"));
foreach (var framework in targetFrameworks)
{
if (!framework.StartsWith("dnxcore"))
{
var publishFolder = Path.Combine(projectFolder, ".testPublish", framework);
DotnetPublish(projectFile, publishFolder, framework);
Copy(runnerFolder, publishFolder, "*.exe", true);
var targetTestDll = projectName + ".dll";
ExecClr("xunit.console.exe", targetTestDll, publishFolder);
}
}
}
}

View File

@ -1,10 +0,0 @@
@Echo off
for /f "delims=" %%i in ('PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.IO.Path]::GetTempFileName()"') do set DNVM_CMD_PATH_FILE=%%i.cmd
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%~dp0dnvm.ps1' %*"
IF EXIST %DNVM_CMD_PATH_FILE% (
CALL %DNVM_CMD_PATH_FILE%
DEL %DNVM_CMD_PATH_FILE%
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@
TestResults/
.nuget/
.build/
.testPublish/
*.sln.ide/
_ReSharper.*/
packages/