1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

test: Use a pretty table for the coverage html

This patch improves the readability and usability of the generated
coverage HTML by making the list of files be a table.
This commit is contained in:
Alberto Bertogli
2020-03-04 00:59:37 +00:00
parent a1ca50ab57
commit 150976b905

View File

@@ -191,6 +191,27 @@ const htmlTmpl = `<!DOCTYPE html>
color: #069; color: #069;
} }
table {
border-collapse: collapse;
}
tr:nth-child(odd) {
background: #f5f5f7;
}
tr.total {
border-top: 1px solid;
font-weight: bold;
}
td {
padding: 0.2em 1em;
}
td.pcnt {
text-align: right;
}
code, pre, tt { code, pre, tt {
font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console,
Terminal, Consolas, Liberation Mono, DejaVu Sans Mono, Terminal, Consolas, Liberation Mono, DejaVu Sans Mono,
@@ -241,13 +262,20 @@ const htmlTmpl = `<!DOCTYPE html>
{{.Notes}}<p> {{.Notes}}<p>
<tt>Total: {{.Totals.TotalPercent | printf "%.2f"}}%</tt><p> <table>
{{range .Files}} {{range .Files}}
<tt><a onclick="visible('f::{{.}}')"> <tr>
{{.}} ({{$.Totals.Percent . | printf "%.1f%%"}})</a></tt><br> <td><a onclick="visible('f::{{.}}')" tabindex="0"> {{.}} </a></td>
<td class="pcnt">{{$.Totals.Percent . | printf "%.1f%%"}}</td>
</tr>
{{- end}} {{- end}}
<tr class="total">
<td>Total</td>
<td class="pcnt">{{.Totals.TotalPercent | printf "%.1f"}}%</td>
</tr>
</table>
<div id="source"> <div id="source">
{{range .Files}} {{range .Files}}
<pre class="file" id="f::{{.}}" style="display: none">{{index $.Code .}}</pre> <pre class="file" id="f::{{.}}" style="display: none">{{index $.Code .}}</pre>