forked from nunit/nunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
130ceba
commit 61fa1a3
Showing
8 changed files
with
343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
var target = Argument("target", "Default"); | ||
var configuration = Argument("configuration", "Debug"); | ||
var framework = Argument("framework", "net-4.5"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// SUPPORTED FRAMEWORKS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
string[] AllFrameworks = new string[] { | ||
"net-4.5", "net-4.0", "net-2.0", "portable" }; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// PREPARATION | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
// Versioning | ||
var packageVersion = "3.1.0"; | ||
|
||
// Directories | ||
//var baseDir = Directory("."); | ||
//var srcDir = Directory("./src"); | ||
//var nugetDir = Directory("./nuget"); | ||
//var toolsDir = Directory("./tools"); | ||
//var libDir = Directory ("./lib"); | ||
var binDir = Directory("./bin") + Directory(configuration); | ||
|
||
// Test Runners | ||
var NUNIT3_CONSOLE = binDir + File("nunit3-console.exe"); | ||
var PORTABLE_RUNNER = binDir + File("portable/nunit.portable.tests.exe"); | ||
|
||
// Test Assemblies | ||
var FRAMEWORK_TESTS = "nunit.framework.tests.dll"; | ||
var NUNITLITE_TESTS = "nunitlite.tests.exe"; | ||
var ENGINE_TESTS = "nunit.engine.tests.dll"; | ||
var ADDIN_TESTS = "addins/tests/addin-tests.dll"; | ||
var V2_DRIVER_TESTS = "addins/v2-tests/nunit.v2.driver.tests.dll"; | ||
var CONSOLE_TESTS = "nunit3-console.tests.dll"; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// SETUP / TEARDOWN | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Setup(() => | ||
{ | ||
Information("Building version {0} of Nunit.", packageVersion); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASKS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Clean") | ||
.Does(() => | ||
{ | ||
CleanDirectory(binDir); | ||
}); | ||
|
||
|
||
Task("Restore-NuGet-Packages") | ||
.Does(() => | ||
{ | ||
NuGetRestore("./nunit.sln"); | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("Restore-NuGet-Packages") | ||
.Does(() => | ||
{ | ||
if(IsRunningOnWindows()) | ||
{ | ||
// Use MSBuild | ||
MSBuild("./nunit.sln", new MSBuildSettings() | ||
.SetConfiguration(configuration) | ||
.SetPlatformTarget(PlatformTarget.MSIL) | ||
// .WithProperty("TreatWarningsAsErrors", "true") | ||
.SetVerbosity(Verbosity.Minimal) | ||
.SetNodeReuse(false) | ||
); | ||
} | ||
else | ||
{ | ||
// Use XBuild | ||
XBuild("./nunit.sln", new XBuildSettings() | ||
.SetConfiguration(configuration) | ||
.WithTarget("AnyCPU") | ||
// .WithProperty("TreatWarningsAsErrors", "true") | ||
.SetVerbosity(Verbosity.Minimal) | ||
); | ||
} | ||
}); | ||
|
||
Task("TestAllFrameworks") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
foreach(string runtime in AllFrameworks) | ||
{ | ||
RunFrameworkTests(runtime); | ||
RunNUnitLiteTests(runtime); | ||
} | ||
}); | ||
|
||
Task("TestFramework") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
RunFrameworkTests(framework); | ||
}); | ||
|
||
Task("TestNUnitLite") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
RunNUnitLiteTests(framework); | ||
}); | ||
|
||
Task("TestEngine") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
RunTestWithConsoleRunner(ENGINE_TESTS); | ||
}); | ||
|
||
Task("TestAddins") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
RunTestWithConsoleRunner(ADDIN_TESTS); | ||
}); | ||
|
||
Task("TestV2Driver") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
RunTestWithConsoleRunner(V2_DRIVER_TESTS); | ||
}); | ||
|
||
Task("TestConsole") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
RunTestWithConsoleRunner(CONSOLE_TESTS); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// HELPER METHODS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
void RunExecutableTest(FilePath exePath) | ||
{ | ||
StartProcess(exePath, new ProcessSettings() | ||
{ | ||
WorkingDirectory = binDir | ||
}); | ||
} | ||
|
||
void RunTestWithConsoleRunner(string testAssembly) | ||
{ | ||
StartProcess(NUNIT3_CONSOLE, new ProcessSettings() | ||
{ | ||
Arguments = testAssembly, | ||
WorkingDirectory = binDir | ||
}); | ||
} | ||
|
||
void RunNUnitLiteTests(string runtime) | ||
{ | ||
RunExecutableTest(binDir + File(runtime + "/" + NUNITLITE_TESTS)); | ||
} | ||
|
||
void RunFrameworkTests(string runtime) | ||
{ | ||
if (runtime == "portable") | ||
RunExecutableTest(PORTABLE_RUNNER); | ||
else | ||
RunTestWithConsoleRunner(runtime + "/" + FRAMEWORK_TESTS); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASK TARGETS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Rebuild") | ||
.IsDependentOn("Clean") | ||
.IsDependentOn("Build"); | ||
|
||
Task("TestAll") | ||
.IsDependentOn("TestAllFrameworks") | ||
.IsDependentOn("TestEngine") | ||
.IsDependentOn("TestAddins") | ||
.IsDependentOn("TestV2Driver") | ||
.IsDependentOn("TestConsole"); | ||
|
||
Task("Test") | ||
.IsDependentOn("TestFramework") | ||
.IsDependentOn("TestNUnitLite") | ||
.IsDependentOn("TestEngine") | ||
.IsDependentOn("TestAddins") | ||
.IsDependentOn("TestV2Driver") | ||
.IsDependentOn("TestConsole"); | ||
|
||
Task("Default") | ||
.IsDependentOn("Build"); // Rebuild? | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// EXECUTION | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
RunTarget(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Param( | ||
[string]$Script = "build.cake", | ||
[string]$Target = "Default", | ||
[ValidateSet("Release", "Debug")] | ||
[string]$Configuration = "Release", | ||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] | ||
[string]$Verbosity = "Verbose", | ||
[switch]$Experimental, | ||
[switch]$WhatIf | ||
) | ||
|
||
$TOOLS_DIR = Join-Path $PSScriptRoot "tools" | ||
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" | ||
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" | ||
|
||
# Should we use experimental build of Roslyn? | ||
$UseExperimental = ""; | ||
if($Experimental.IsPresent) { | ||
$UseExperimental = "-experimental" | ||
} | ||
|
||
# Is this a dry run? | ||
$UseDryRun = ""; | ||
if($WhatIf.IsPresent) { | ||
$UseDryRun = "-dryrun" | ||
} | ||
|
||
# Try download NuGet.exe if do not exist. | ||
if (!(Test-Path $NUGET_EXE)) { | ||
Invoke-WebRequest -Uri http://nuget.org/nuget.exe -OutFile $NUGET_EXE | ||
} | ||
|
||
# Make sure NuGet exists where we expect it. | ||
if (!(Test-Path $NUGET_EXE)) { | ||
Throw "Could not find NuGet.exe" | ||
} | ||
|
||
# Restore tools from NuGet. | ||
Push-Location | ||
Set-Location $TOOLS_DIR | ||
Invoke-Expression "$NUGET_EXE install -ExcludeVersion" | ||
Pop-Location | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} | ||
|
||
# Make sure that Cake has been installed. | ||
if (!(Test-Path $CAKE_EXE)) { | ||
Throw "Could not find Cake.exe" | ||
} | ||
|
||
# Start Cake | ||
Invoke-Expression "$CAKE_EXE `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseDryRun $UseExperimental" | ||
Write-Host | ||
exit $LASTEXITCODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
############################################################### | ||
# This is the Cake bootstrapper script that is responsible for | ||
# downloading Cake and all specified tools from NuGet. | ||
############################################################### | ||
|
||
# Define directories. | ||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TOOLS_DIR=$SCRIPT_DIR/tools | ||
NUGET_EXE=$TOOLS_DIR/nuget.exe | ||
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe | ||
|
||
# Define default arguments. | ||
SCRIPT="build.cake" | ||
TARGET="Default" | ||
CONFIGURATION="Release" | ||
VERBOSITY="verbose" | ||
DRYRUN=false | ||
SHOW_VERSION=false | ||
|
||
# Parse arguments. | ||
for i in "$@"; do | ||
case $1 in | ||
-s|--script) SCRIPT="$2"; shift ;; | ||
-t|--target) TARGET="$2"; shift ;; | ||
-c|--configuration) CONFIGURATION="$2"; shift ;; | ||
-v|--verbosity) VERBOSITY="$2"; shift ;; | ||
-d|--dryrun) DRYRUN=true ;; | ||
--version) SHOW_VERSION=true ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Download NuGet if it does not exist. | ||
if [ ! -f $NUGET_EXE ]; then | ||
echo "Downloading NuGet..." | ||
curl -Lsfo $NUGET_EXE https://www.nuget.org/nuget.exe | ||
if [ $? -ne 0 ]; then | ||
echo "An error occured while downloading nuget.exe." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Restore tools from NuGet. | ||
pushd $TOOLS_DIR >/dev/null | ||
mono $NUGET_EXE install -ExcludeVersion | ||
popd >/dev/null | ||
|
||
# Make sure that Cake has been installed. | ||
if [ ! -f $CAKE_EXE ]; then | ||
echo "Could not find Cake.exe." | ||
exit 1 | ||
fi | ||
|
||
# Start Cake | ||
if $SHOW_VERSION; then | ||
mono $CAKE_EXE -version | ||
elif $DRYRUN; then | ||
mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET -dryrun | ||
echo | ||
else | ||
mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET | ||
echo | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
tools\Cake\Cake.exe %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
powershell ./build.ps1 %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Cake" version="0.6.0" /> | ||
</packages> |