diff options
Diffstat (limited to 'pkg/cover')
| -rw-r--r-- | pkg/cover/heatmap.go | 11 | ||||
| -rw-r--r-- | pkg/cover/heatmap_test.go | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/pkg/cover/heatmap.go b/pkg/cover/heatmap.go index bdb79eec4..751b53ea6 100644 --- a/pkg/cover/heatmap.go +++ b/pkg/cover/heatmap.go @@ -279,7 +279,16 @@ func FormatResult(thm *templateHeatmap, format Format) { }) // We want to show the coverage drop numbers instead of total instrumented blocks. thm.Transform(func(row *templateHeatmapRow) { - row.Summary = -1 * (slices.Max(row.Covered) - row.Covered[len(row.Covered)-1]) + if !row.IsDir { + row.Summary = -1 * (slices.Max(row.Covered) - row.Covered[len(row.Covered)-1]) + return + } + row.Summary = 0 + for _, item := range row.Items { + if item.Summary < 0 { // only the items with coverage drop + row.Summary += item.Summary + } + } }) } } diff --git a/pkg/cover/heatmap_test.go b/pkg/cover/heatmap_test.go index 41e643cf2..1c094f1dd 100644 --- a/pkg/cover/heatmap_test.go +++ b/pkg/cover/heatmap_test.go @@ -305,10 +305,12 @@ func TestFormatResult(t *testing.T) { Name: "dir", Covered: []int64{1, 1}, IsDir: true, + Summary: -15, }, }, Covered: []int64{1, 1}, IsDir: true, + Summary: -15, }, }, }, |
