From 290f6e6a145f8b2a903bece9387e3edc58731a54 Mon Sep 17 00:00:00 2001 From: "Todd V. Jonker" Date: Wed, 4 Feb 2026 11:29:09 -0800 Subject: [PATCH] Print a link to the fcov report after a build. This makes it clickable from the shell. --- .../main/java/dev/ionfusion/fusion/cli/Cover.java | 5 +++-- .../ionfusion/fusion/cli/CoverageReportWriter.java | 14 ++++++++++---- .../java/dev/ionfusion/fusion/cli/CoverTest.java | 10 +++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/runtime/src/main/java/dev/ionfusion/fusion/cli/Cover.java b/runtime/src/main/java/dev/ionfusion/fusion/cli/Cover.java index fce7410e3..300ce1f60 100644 --- a/runtime/src/main/java/dev/ionfusion/fusion/cli/Cover.java +++ b/runtime/src/main/java/dev/ionfusion/fusion/cli/Cover.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.PrintWriter; +import java.nio.file.Path; /** * @@ -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; } diff --git a/runtime/src/main/java/dev/ionfusion/fusion/cli/CoverageReportWriter.java b/runtime/src/main/java/dev/ionfusion/fusion/cli/CoverageReportWriter.java index bd789e463..d3ae2c02e 100644 --- a/runtime/src/main/java/dev/ionfusion/fusion/cli/CoverageReportWriter.java +++ b/runtime/src/main/java/dev/ionfusion/fusion/cli/CoverageReportWriter.java @@ -667,10 +667,10 @@ private 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); @@ -699,7 +699,10 @@ 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(); @@ -707,6 +710,9 @@ public void renderFullReport(File outputDir) prepareRelativeNames(); renderSourceFiles(outputDir); - renderIndex(outputDir); + + Path indexFile = outputDir.toPath().resolve("index.html"); + renderIndex(indexFile); + return indexFile; } } diff --git a/runtime/src/test/java/dev/ionfusion/fusion/cli/CoverTest.java b/runtime/src/test/java/dev/ionfusion/fusion/cli/CoverTest.java index 2235e4db0..ceef1c972 100644 --- a/runtime/src/test/java/dev/ionfusion/fusion/cli/CoverTest.java +++ b/runtime/src/test/java/dev/ionfusion/fusion/cli/CoverTest.java @@ -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; @@ -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()); }