Skip to content

Commit

Permalink
Merge branch '79-the-coverage-data-is-not-create-in-the-trial-folder'…
Browse files Browse the repository at this point in the history
… into 'master'

Resolve "the coverage data is not create in the `.trial` folder"

Closes #79

See merge request szabobogdan3/trial!74
  • Loading branch information
Szabo Bogdan committed Aug 8, 2018
2 parents 9054b8b + 661d2a8 commit 5ee259d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lifecycle/trial/coverage.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ version(D_Coverage) {
}

/// Converts coverage lst files to html
double convertLstFiles(string packagePath, string packageName) {
if(!exists(buildPath("coverage", "raw"))) {
double convertLstFiles(string source, string destination, string packagePath, string packageName) {
auto htmlPath = buildPath(destination, "html");
if(!source.exists) {
return 0;
}

if(!exists(buildPath("coverage", "html"))) {
mkdirRecurse(buildPath("coverage", "html"));
if(!htmlPath.exists) {
htmlPath.mkdirRecurse;
}

std.file.write(buildPath("coverage", "html", "coverage.css"), import("templates/coverage.css"));
std.file.write(buildPath(htmlPath, "coverage.css"), import("templates/coverage.css"));

auto coverageData =
dirEntries(buildPath("coverage", "raw"), SpanMode.shallow)
Expand All @@ -56,13 +57,13 @@ double convertLstFiles(string packagePath, string packageName) {
.map!(a => readText(a.name))
.map!(a => a.toCoverageFile(packagePath)).array;

std.file.write(buildPath("coverage", "html", "coverage-shield.svg"), coverageShield(coverageData.filter!"a.isInCurrentProject".array.coveragePercent.to!int.to!string));
std.file.write(buildPath("coverage", "html", "index.html"), coverageData.toHtmlIndex(packageName));
std.file.write(buildPath(htmlPath, "coverage-shield.svg"), coverageShield(coverageData.filter!"a.isInCurrentProject".array.coveragePercent.to!int.to!string));
std.file.write(buildPath(htmlPath, "index.html"), coverageData.toHtmlIndex(packageName));

foreach (data; coverageData) {
auto htmlFile = data.path.toCoverageHtmlFileName;

std.file.write(buildPath("coverage", "html", htmlFile), data.toHtml);
std.file.write(buildPath(htmlPath, htmlFile), data.toHtml);
}

return coverageData.coveragePercent;
Expand Down
6 changes: 5 additions & 1 deletion runner/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ version(unitttest) {} else {
return 1;
} finally {
if(arguments.canFind("--coverage")) {
string source = buildPath("coverage", "raw");
string destination = buildPath(runnerSettings.settings.artifactsLocation, "coverage");
logDiagnostic("calculate the code coverage");
writeln("Line coverage: ", convertLstFiles(dub.rootPath.toString, dub.projectName), "%");

writeln("Line coverage: ",
convertLstFiles(source, destination, dub.rootPath.toString, dub.projectName), "%");
}
}

Expand Down

0 comments on commit 5ee259d

Please sign in to comment.