Skip to content

Commit

Permalink
fix: escape directory in dotnet test to avoid errors with directories…
Browse files Browse the repository at this point in the history
… with whitespaces
  • Loading branch information
saintedlama committed Dec 17, 2018
1 parent 7d6bf5f commit 992ff6e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Testeroid/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static int Main(string[] args)
Coverage coverage = new Coverage(testDll, excludes, includes, new string[0], lastCoverageReport);
coverage.PrepareModules();
var dotnetTest = "dotnet".Execute($"test {project.GetDirectory()} --no-build --no-restore {testLogger}", workingDirectory: workingDirectory.Path.FullName);
var dotnetTest = "dotnet".Execute($"test {EscapeDirectory(project.GetDirectory())} --no-build --no-restore {testLogger}", workingDirectory: workingDirectory.Path.FullName);
Verbose(dotnetTest.StandardOutput);
Expand Down Expand Up @@ -170,7 +170,7 @@ public static int Main(string[] args)
lastCoverageReport = BuildIntermediateCoverletReport(coverageResult);
}
}
catch (Exception ex)
catch (Exception)
{
Information($"An error occurred while executing 'dotnet test' for project '{project.GetDirectory()}'");
throw;
Expand Down Expand Up @@ -209,6 +209,16 @@ private static void DeleteFile(string filePath)
}
}

private static string EscapeDirectory(string directory)
{
if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
{
return $"'{directory}'";
}

return $"\"{directory}\"";
}

private static IReport BuildResultReportsPipeline(string outputPath, List<string> reports)
{
return new ReportPipeline(
Expand Down

0 comments on commit 992ff6e

Please sign in to comment.