Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions runtime/src/main/java/dev/ionfusion/fusion/cli/Cover.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.File;
import java.io.PrintWriter;
import java.nio.file.Path;

/**
*
Expand Down Expand Up @@ -77,10 +78,10 @@ public int execute(PrintWriter out, PrintWriter err)
{
CoverageReportWriter renderer = new CoverageReportWriter(myDataDir);

renderer.renderFullReport(myReportDir);
Path index = renderer.renderFullReport(myReportDir);

out.print("Wrote Fusion coverage report to ");
out.println(myReportDir.getPath());
out.println(index.toUri());

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,10 @@ private <T> void renderRows(HtmlWriter indexHtml,
}


private void renderIndex(File outputDir)
private void renderIndex(Path indexFile)
throws IOException
{
try (StreamWriter out = new StreamWriter(outputDir, "index.html"))
try (StreamWriter out = new StreamWriter(indexFile))
{
HtmlWriter indexHtml = new HtmlWriter(out);
indexHtml.renderHeadWithInlineCss("Fusion Code Coverage", CSS);
Expand Down Expand Up @@ -699,14 +699,20 @@ private void renderIndex(File outputDir)
}


public void renderFullReport(File outputDir)
/**
* @return the path of the index file.
*/
public Path renderFullReport(File outputDir)
throws FusionException, IOException
{
analyze();

prepareRelativeNames();

renderSourceFiles(outputDir);
renderIndex(outputDir);

Path indexFile = outputDir.toPath().resolve("index.html");
renderIndex(indexFile);
return indexFile;
}
}
10 changes: 7 additions & 3 deletions runtime/src/test/java/dev/ionfusion/fusion/cli/CoverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
package dev.ionfusion.fusion.cli;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -98,8 +101,9 @@ public void testCoverCompletionMessage()
// I'm surprised this works without any coverage data!
run(0, "report_coverage", dataDir, reportDir);
assertThat(stdoutText,
containsString("Wrote Fusion coverage report to " + reportDir));
assertThat(stderrText, isEmptyString());
allOf(containsString("Wrote Fusion coverage report to "),
containsString(reportDir)));
assertThat(stderrText, is(emptyString()));

assertTrue(new File(reportDir, "index.html").isFile());
}
Expand Down