From 150976b905e30d2db4eb1a56db2db0694f03108c Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Wed, 4 Mar 2020 00:59:37 +0000 Subject: [PATCH] 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. --- test/util/coverhtml.go | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/test/util/coverhtml.go b/test/util/coverhtml.go index 85f91b0..768e99a 100644 --- a/test/util/coverhtml.go +++ b/test/util/coverhtml.go @@ -191,6 +191,27 @@ const htmlTmpl = ` 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 { font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal, Consolas, Liberation Mono, DejaVu Sans Mono, @@ -241,13 +262,20 @@ const htmlTmpl = ` {{.Notes}}

- Total: {{.Totals.TotalPercent | printf "%.2f"}}%

- + {{range .Files}} - - {{.}} ({{$.Totals.Percent . | printf "%.1f%%"}})
+ + + + {{- end}} + + + + +
{{.}} {{$.Totals.Percent . | printf "%.1f%%"}}
Total{{.Totals.TotalPercent | printf "%.1f"}}%
+

{{range .Files}}