diff options
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/cover/html.go | 25 | ||||
| -rw-r--r-- | pkg/cover/report_test.go | 43 | ||||
| -rw-r--r-- | pkg/mgrconfig/config.go | 4 |
3 files changed, 69 insertions, 3 deletions
diff --git a/pkg/cover/html.go b/pkg/cover/html.go index ae4aa6c4b..042d28b40 100644 --- a/pkg/cover/html.go +++ b/pkg/cover/html.go @@ -537,8 +537,12 @@ func groupCoverByFilePrefixes(datas []fileStats, subsystems []mgrconfig.Subsyste var percentCoveredFunc float64 for _, path := range subsystem.Paths { + if strings.HasPrefix(path, "-") { + continue + } + excludes := buildExcludePaths(path, subsystem.Paths) for _, data := range datas { - if !strings.HasPrefix(data.Name, path) { + if !strings.HasPrefix(data.Name, path) || isExcluded(data.Name, excludes) { continue } coveredLines += data.CoveredLines @@ -582,6 +586,25 @@ func groupCoverByFilePrefixes(datas []fileStats, subsystems []mgrconfig.Subsyste return d } +func buildExcludePaths(prefix string, paths []string) []string { + var excludes []string + for _, path := range paths { + if strings.HasPrefix(path, "-") && strings.HasPrefix(path[1:], prefix) { + excludes = append(excludes, path[1:]) + } + } + return excludes +} + +func isExcluded(path string, excludes []string) bool { + for _, exclude := range excludes { + if strings.HasPrefix(path, exclude) { + return true + } + } + return false +} + func (rg *ReportGenerator) DoSubsystemCover(w io.Writer, params HandlerParams) error { var progs = fixUpPCs(params.Progs, params.Filter) data, err := rg.convertToStats(progs) 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%", + }) +} diff --git a/pkg/mgrconfig/config.go b/pkg/mgrconfig/config.go index 42730eef4..6bf88c574 100644 --- a/pkg/mgrconfig/config.go +++ b/pkg/mgrconfig/config.go @@ -51,9 +51,9 @@ type Config struct { KernelBuildSrc string `json:"kernel_build_src,omitempty"` // Is the kernel built separately from the modules? (Specific to Android builds) AndroidSplitBuild bool `json:"android_split_build"` - // Kernel subsystem with paths to each subsystem + // Kernel subsystem with paths to each subsystem, paths starting with "-" will be excluded // "kernel_subsystem": [ - // { "name": "sound", "path": ["sound", "techpack/audio"]}, + // { "name": "sound", "path": ["sound", "techpack/audio", "-techpack/audio/dsp"]}, // { "name": "mydriver": "path": ["mydriver_path"]} // ] KernelSubsystem []Subsystem `json:"kernel_subsystem,omitempty"` |
