Run tests during build

This commit is contained in:
Brice Lambson 2014-02-28 11:26:33 -08:00
parent 90430b425d
commit 9d6b227226
2 changed files with 36 additions and 0 deletions

View File

@ -60,6 +60,9 @@ default Configuration='Release'
#nuget-install target='install' description='Copy NuGet packages to local repo'
nuget-local-publish sourcePackagesDir='${BUILD_DIR}'
#xunit-test target='test' if='Directory.Exists("test")'
k-test each='var projectFile in Files.Include("test/**/project.json")'
#make-roslyn-fast
ngen-roslyn

33
build/_k-test.shade Normal file
View File

@ -0,0 +1,33 @@
use namespace='System.Web.Script.Serialization'
use assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
@{/*
k-test
Run unit tests in your project.
projectFile=''
Required. Path to the test project.json to execute
*/}
var projectFolder='${Path.GetDirectoryName(projectFile)}'
k command='test' workingdir='${projectFolder}' if='HasTestCommand(projectFile)'
functions
@{
bool HasTestCommand(string projectFile)
{
var serializer = new JavaScriptSerializer();
var projectText = File.ReadAllText(projectFile);
var project = (Dictionary<string, object>)serializer.DeserializeObject(projectText);
object commandsObject;
if (!project.TryGetValue("commands", out commandsObject))
return false;
var commands = (Dictionary<string, object>)commandsObject;
return commands.Keys.Contains("test");
}
}