Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Improved test execution task
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodejunkie committed Jun 2, 2017
1 parent d0b713b commit e48bb0e
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ Task("Compile")
var content =
System.IO.File.ReadAllText(project.FullPath, Encoding.UTF8);
if (IsRunningOnUnix() && content.Contains(">" + fullFrameworkTarget + "<")) {
if (IsRunningOnUnix() && content.Contains(">" + fullFrameworkTarget + "<"))
{
Information(project.GetFilename() + " only supports " +fullFrameworkTarget + " and cannot be built on *nix. Skipping.");
continue;
}
DotNetCoreBuild(project.GetDirectory().FullPath, new DotNetCoreBuildSettings {
ArgumentCustomization = args => {
if (IsRunningOnUnix()) {
if (IsRunningOnUnix())
{
args.Append(string.Concat("-f ", project.GetDirectory().GetDirectoryName().Contains(".Tests") ? netCoreTarget : netStandardTarget));
}
Expand Down Expand Up @@ -135,7 +137,8 @@ Task("Publish-NuGet")
.Description("Pushes the nuget packages in the nuget folder to a NuGet source. Also publishes the packages into the feeds.")
.Does(() =>
{
if(string.IsNullOrWhiteSpace(apiKey)) {
if(string.IsNullOrWhiteSpace(apiKey))
{
throw new CakeException("No NuGet API key provided. You need to pass in --apikey=\"xyz\"");
}
Expand Down Expand Up @@ -234,8 +237,15 @@ Task("Test")
.IsDependentOn("Compile")
.Does(() =>
{
/*
Exclude Nancy.ViewEngines.Spark.Tests from test execution until their problem
with duplicate assembly references (if the same assembly exists more than once
in the application domain, it fails to compile the views) has been fixed.
*/
var projects =
GetFiles("./test/**/*.csproj");
GetFiles("./test/**/*.csproj") -
GetFiles("./test/Nancy.ViewEngines.Spark.Tests/Nancy.ViewEngines.Spark.Tests.csproj");
if (projects.Count == 0)
{
Expand All @@ -247,21 +257,28 @@ Task("Test")
var content =
System.IO.File.ReadAllText(project.FullPath, Encoding.UTF8);
if (IsRunningOnUnix() && content.Contains(">" + fullFrameworkTarget + "<")) {
if (IsRunningOnUnix() && content.Contains(">" + fullFrameworkTarget + "<"))
{
Information(project.GetFilename() + " only supports " +fullFrameworkTarget + " and tests cannot be executed on *nix. Skipping.");
continue;
}
var settings = new ProcessSettings {
Arguments = string.Concat("xunit -configuration ", configuration, " -nobuild -verbose"),
Arguments = string.Concat("xunit -configuration ", configuration, " -nobuild"),
WorkingDirectory = project.GetDirectory()
};
if (IsRunningOnUnix()) {
if (IsRunningOnUnix())
{
settings.Arguments.Append(string.Concat("-framework ", netCoreTarget));
}
StartProcess("dotnet", settings);
Information("Executing tests for " + project.GetFilename() + " with arguments: " + settings.Arguments.Render());
if (StartProcess("dotnet", settings) != 0)
{
Error("One or more tests failed during execution of: " + project.GetFilename());
}
}
});

Expand All @@ -270,7 +287,8 @@ Task("Update-Version")
{
Information("Setting version to " + version);
if(string.IsNullOrWhiteSpace(version)) {
if(string.IsNullOrWhiteSpace(version))
{
throw new CakeException("No version specified! You need to pass in --targetversion=\"x.y.z\"");
}
Expand Down

0 comments on commit e48bb0e

Please sign in to comment.