mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(coverage): HTML validation errors in coverage explorer (#29497)
Closes #29493
This commit is contained in:
parent
ab9673dcc1
commit
f9bb8241ca
3 changed files with 7 additions and 8 deletions
|
@ -505,7 +505,7 @@ impl HtmlCoverageReporter {
|
||||||
let footer = self.create_html_footer(timestamp);
|
let footer = self.create_html_footer(timestamp);
|
||||||
format!(
|
format!(
|
||||||
"<!doctype html>
|
"<!doctype html>
|
||||||
<html>
|
<html lang='en-US'>
|
||||||
{head}
|
{head}
|
||||||
<body>
|
<body>
|
||||||
<div class='wrapper'>
|
<div class='wrapper'>
|
||||||
|
@ -530,7 +530,7 @@ impl HtmlCoverageReporter {
|
||||||
<meta charset='utf-8'>
|
<meta charset='utf-8'>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<style>{style_css}</style>
|
<style>{style_css}</style>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||||
</head>"
|
</head>"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -658,7 +658,7 @@ impl HtmlCoverageReporter {
|
||||||
) -> String {
|
) -> String {
|
||||||
let line_num = file_text.lines().count();
|
let line_num = file_text.lines().count();
|
||||||
let line_count = (1..line_num + 1)
|
let line_count = (1..line_num + 1)
|
||||||
.map(|i| format!("<a name='L{i}'></a><a href='#L{i}'>{i}</a>"))
|
.map(|i| format!("<a href='#L{i}' id='L{i}'>{i}</a>"))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
let line_coverage = (0..line_num)
|
let line_coverage = (0..line_num)
|
||||||
|
@ -667,12 +667,12 @@ impl HtmlCoverageReporter {
|
||||||
report.found_lines.iter().find(|(line, _)| i == *line)
|
report.found_lines.iter().find(|(line, _)| i == *line)
|
||||||
{
|
{
|
||||||
if *count == 0 {
|
if *count == 0 {
|
||||||
"<span class='cline-any cline-no'> </span>".to_string()
|
"<span class='cline-any cline-no'> </span>".to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("<span class='cline-any cline-yes' title='This line is covered {count} time{}'>x{count}</span>", if *count > 1 { "s" } else { "" })
|
format!("<span class='cline-any cline-yes' title='This line is covered {count} time{}'>x{count}</span>", if *count > 1 { "s" } else { "" })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"<span class='cline-any cline-neutral'> </span>".to_string()
|
"<span class='cline-any cline-neutral'> </span>".to_string()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
|
@ -557,8 +557,7 @@ fn test_html_reporter() {
|
||||||
// Check <T> in source code is escaped to <T>
|
// Check <T> in source code is escaped to <T>
|
||||||
assert_contains!(bar_ts_html, "<T>");
|
assert_contains!(bar_ts_html, "<T>");
|
||||||
// Check that line anchors are correctly referenced by line number links
|
// 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' id='L1'>1</a>");
|
||||||
assert_contains!(bar_ts_html, "<a href='#L1'>1</a>");
|
|
||||||
|
|
||||||
let baz_index_html = tempdir
|
let baz_index_html = tempdir
|
||||||
.join("html")
|
.join("html")
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>[WILDCARD]</html>
|
<html lang='en-US'>[WILDCARD]</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue