diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-04-11 20:27:12 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-04-22 12:28:29 +0000 |
| commit | ee0bd1607af85b55b2a3094f4981a1946286fac5 (patch) | |
| tree | 80e469f7a993ce3cd5ede6feecba29b0adf27575 /pkg/cover | |
| parent | 2a20f901dbd7922a27b5625a8a442587c8c3df2c (diff) | |
dashboard/app: aggregate coverage drop numbers bottom-up
Tree view now shows the total drop for every item.
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, }, }, }, |
