diff options
author | Simon Lecoq <22963968+lowlighter@users.noreply.github.com> | 2024-05-21 07:37:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 13:37:36 +0200 |
commit | fa5c61e441b88204dbcee334ebf4478b9f0949c5 (patch) | |
tree | a140980e87a07364a352886ee2eb3e302738cabf | |
parent | c703ddd965655fc4482a1fd959baee61bb26097c (diff) |
fix(cli/coverage): invalid line id in html reporter (#23908)
-rw-r--r-- | cli/tools/coverage/reporter.rs | 2 | ||||
-rw-r--r-- | tests/integration/coverage_tests.rs | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/cli/tools/coverage/reporter.rs b/cli/tools/coverage/reporter.rs index 6547f2036..f359755a9 100644 --- a/cli/tools/coverage/reporter.rs +++ b/cli/tools/coverage/reporter.rs @@ -633,7 +633,7 @@ impl HtmlCoverageReporter { ) -> String { let line_num = file_text.lines().count(); let line_count = (1..line_num + 1) - .map(|i| format!("<a name='L{i}'></a><a href='#{i}'>{i}</a>")) + .map(|i| format!("<a name='L{i}'></a><a href='#L{i}'>{i}</a>")) .collect::<Vec<_>>() .join("\n"); let line_coverage = (0..line_num) diff --git a/tests/integration/coverage_tests.rs b/tests/integration/coverage_tests.rs index 6e9a1454c..ae732f25f 100644 --- a/tests/integration/coverage_tests.rs +++ b/tests/integration/coverage_tests.rs @@ -486,6 +486,9 @@ fn test_html_reporter() { assert_contains!(bar_ts_html, "<h1>Coverage report for bar.ts</h1>"); // Check <T> in source code is escaped to <T> assert_contains!(bar_ts_html, "<T>"); + // Check that line anchors are correctly referenced by line number links + assert_contains!(bar_ts_html, "<a name='L1'></a>"); + assert_contains!(bar_ts_html, "<a href='#L1'>1</a>"); let baz_index_html = tempdir .join("html") |