Skip to content

Commit f380f3d

Browse files
quic-likaidjiangenj
authored andcommitted
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" ] }
1 parent c37c724 commit f380f3d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pkg/cover/html.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,29 @@ func groupCoverByFilePrefixes(datas []fileStats, subsystems []mgrconfig.Subsyste
445445
var percentCoveredFunc float64
446446

447447
for _, path := range subsystem.Paths {
448+
if strings.HasPrefix(path, "-") {
449+
continue
450+
}
451+
var excludes []string
452+
for _, exclude := range subsystem.Paths {
453+
if strings.HasPrefix(exclude, "-") && strings.HasPrefix(exclude[1:], path) {
454+
excludes = append(excludes, exclude[1:])
455+
}
456+
}
448457
for _, data := range datas {
449458
if !strings.HasPrefix(data.Name, path) {
450459
continue
451460
}
461+
excluded := false
462+
for _, exclude := range excludes {
463+
if strings.HasPrefix(data.Name, exclude) {
464+
excluded = true
465+
break
466+
}
467+
}
468+
if excluded {
469+
continue
470+
}
452471
coveredLines += data.CoveredLines
453472
totalLines += data.TotalLines
454473
coveredPCsInFile += data.CoveredPCs

pkg/mgrconfig/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ type Config struct {
5151
KernelBuildSrc string `json:"kernel_build_src,omitempty"`
5252
// Is the kernel built separately from the modules? (Specific to Android builds)
5353
AndroidSplitBuild bool `json:"android_split_build"`
54-
// Kernel subsystem with paths to each subsystem
54+
// Kernel subsystem with paths to each subsystem, paths starting with "-" will be excluded
5555
// "kernel_subsystem": [
56-
// { "name": "sound", "path": ["sound", "techpack/audio"]},
56+
// { "name": "sound", "path": ["sound", "techpack/audio", "-techpack/audio/dsp"]},
5757
// { "name": "mydriver": "path": ["mydriver_path"]}
5858
// ]
5959
KernelSubsystem []Subsystem `json:"kernel_subsystem,omitempty"`

0 commit comments

Comments
 (0)