aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-09-26 18:10:09 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-09-28 09:41:25 +0200
commit772f70e5bd29f244bfcd4365735dc35d6564d1fb (patch)
tree23e728d18d2e16bddfc94bc25f9658340cb77140 /pkg
parent2111afe851ac1e0302bec299eceec60f7dd0c8b7 (diff)
pkg/cover: fix function coverage in html reports
The HTML code assumes that files and functions match one-to-one as they are identified by indices (file_N should match function_N). Since we only add non-empty functions, this relation is broken and a the report shows function coverage for a random file. Moreover, since the order is based on map iteration (random each time), function coverage shown for a file also randomly changes each time. Follow up to #2074
Diffstat (limited to 'pkg')
-rw-r--r--pkg/cover/report.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/pkg/cover/report.go b/pkg/cover/report.go
index ebf884002..784c470a5 100644
--- a/pkg/cover/report.go
+++ b/pkg/cover/report.go
@@ -355,9 +355,7 @@ func addFunctionCoverage(file *file, data *templateData) {
buf.WriteString(fmt.Sprintf("<span class='cover-right'>of %v", strconv.Itoa(len(function.totalPCs))))
buf.WriteString("</span></span></span><br>\n")
}
- if buf.Len() > 0 {
- data.Functions = append(data.Functions, template.HTML(buf.String()))
- }
+ data.Functions = append(data.Functions, template.HTML(buf.String()))
}
func processDir(dir *templateDir) {