diff options
| author | Kevin Ding <quic_likaid@quicinc.com> | 2025-02-24 10:23:57 +0800 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-03-11 15:17:43 +0000 |
| commit | f2eee6b3351e8cecbbd53e27c4f690a78b9ec2a2 (patch) | |
| tree | bb0c756ad0af8dfcca909d719bc4fd519b8366d1 /pkg/cover/report_test.go | |
| parent | 16256247d9c41cf4980c36db3841ddd674a04b58 (diff) | |
pkg/cover: allow paths to be excluded from stats
Some sub paths may not be covered due to hardware configuration, or lack
of interest. This patch allows them to be excluded from the stats. This
can be convenient if the excluded paths are deep in the hierarchy:
{
"name": "sound",
"path": [
"techpack/audio",
"-techpack/audio/asoc/aaa/bbb"
"-techpack/audio/asoc/aaa/ccc"
]
}
Diffstat (limited to 'pkg/cover/report_test.go')
| -rw-r--r-- | pkg/cover/report_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg/cover/report_test.go b/pkg/cover/report_test.go index 8f27590e9..8c86049f1 100644 --- a/pkg/cover/report_test.go +++ b/pkg/cover/report_test.go @@ -459,3 +459,46 @@ var sampleJSONLlProgs = []byte(`{ } ] }`) + +func makeFileStat(name string) fileStats { + return fileStats{ + Name: name, + CoveredLines: 1, + TotalLines: 8, + CoveredPCs: 1, + TotalPCs: 4, + TotalFunctions: 2, + CoveredFunctions: 1, + CoveredPCsInFunctions: 1, + TotalPCsInCoveredFunctions: 2, + TotalPCsInFunctions: 2, + } +} + +func TestCoverByFilePrefixes(t *testing.T) { + datas := []fileStats{ + makeFileStat("a"), + makeFileStat("a/1"), + makeFileStat("a/2"), + makeFileStat("a/2/A"), + makeFileStat("a/3"), + } + subsystems := []mgrconfig.Subsystem{ + { + Name: "test", + Paths: []string{ + "a", + "-a/2", + }, + }, + } + d := groupCoverByFilePrefixes(datas, subsystems) + assert.Equal(t, d["test"], map[string]string{ + "name": "test", + "lines": "3 / 24 / 12.50%", + "PCsInFiles": "3 / 12 / 25.00%", + "Funcs": "3 / 6 / 50.00%", + "PCsInFuncs": "3 / 6 / 50.00%", + "PCsInCoveredFuncs": "3 / 6 / 50.00%", + }) +} |
