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

Commit 2f6322f

Browse files
committed
Improved test execution task
1 parent d0b713b commit 2f6322f

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

build.cake

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ Task("Publish-NuGet")
135135
.Description("Pushes the nuget packages in the nuget folder to a NuGet source. Also publishes the packages into the feeds.")
136136
.Does(() =>
137137
{
138-
if(string.IsNullOrWhiteSpace(apiKey)) {
138+
if(string.IsNullOrWhiteSpace(apiKey))
139+
{
139140
throw new CakeException("No NuGet API key provided. You need to pass in --apikey=\"xyz\"");
140141
}
141142

@@ -234,8 +235,15 @@ Task("Test")
234235
.IsDependentOn("Compile")
235236
.Does(() =>
236237
{
238+
/*
239+
Exclude Nancy.ViewEngines.Spark.Tests from test execution until their problem
240+
with duplicate assembly references (if the same assembly exists more than once
241+
in the application domain, it fails to compile the views) has been fixed.
242+
*/
243+
237244
var projects =
238-
GetFiles("./test/**/*.csproj");
245+
GetFiles("./test/**/*.csproj") -
246+
GetFiles("./test/Nancy.ViewEngines.Spark.Tests/Nancy.ViewEngines.Spark.Tests.csproj");
239247

240248
if (projects.Count == 0)
241249
{
@@ -247,21 +255,28 @@ Task("Test")
247255
var content =
248256
System.IO.File.ReadAllText(project.FullPath, Encoding.UTF8);
249257

250-
if (IsRunningOnUnix() && content.Contains(">" + fullFrameworkTarget + "<")) {
258+
if (IsRunningOnUnix() && content.Contains(">" + fullFrameworkTarget + "<"))
259+
{
251260
Information(project.GetFilename() + " only supports " +fullFrameworkTarget + " and tests cannot be executed on *nix. Skipping.");
252261
continue;
253262
}
254263

255264
var settings = new ProcessSettings {
256-
Arguments = string.Concat("xunit -configuration ", configuration, " -nobuild -verbose"),
265+
Arguments = string.Concat("xunit -configuration ", configuration, " -nobuild"),
257266
WorkingDirectory = project.GetDirectory()
258267
};
259268

260-
if (IsRunningOnUnix()) {
269+
if (IsRunningOnUnix())
270+
{
261271
settings.Arguments.Append(string.Concat("-framework ", netCoreTarget));
262272
}
263273

264-
StartProcess("dotnet", settings);
274+
Information("Executing tests for " + project.GetFilename() + " with arguments: " + settings.Arguments.Render());
275+
276+
if (StartProcess("dotnet", settings) != 0)
277+
{
278+
Error("One or more tests failed during execution of: " + project.GetFilename());
279+
}
265280
}
266281
});
267282

0 commit comments

Comments
 (0)