Change syntax for jacoco filter wildcard params.
originally: .* -> /**/*.class now: .* -> /*.class .** -> /**/*.class Also add NinjaAndShellEscape to allow filtering inner classes with $ in the name. Test: unittests. Bug: b/71889972 Merged-In: Ifb8d7daa22bee02346885171edb15180af18f0de Change-Id: Ifb8d7daa22bee02346885171edb15180af18f0de (cherry picked from commit c61066684d5c8ddf600af602852c32fce6e6c6f4)
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
@@ -105,13 +106,22 @@ func jacocoFiltersToSpecs(filters []string) ([]string, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specs, nil
|
return proptools.NinjaAndShellEscape(specs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func jacocoFilterToSpec(filter string) (string, error) {
|
func jacocoFilterToSpec(filter string) (string, error) {
|
||||||
wildcard := strings.HasSuffix(filter, "*")
|
recursiveWildcard := strings.HasSuffix(filter, "**")
|
||||||
|
nonRecursiveWildcard := false
|
||||||
|
if !recursiveWildcard {
|
||||||
|
nonRecursiveWildcard = strings.HasSuffix(filter, "*")
|
||||||
filter = strings.TrimSuffix(filter, "*")
|
filter = strings.TrimSuffix(filter, "*")
|
||||||
recursiveWildcard := wildcard && (strings.HasSuffix(filter, ".") || filter == "")
|
} else {
|
||||||
|
filter = strings.TrimSuffix(filter, "**")
|
||||||
|
}
|
||||||
|
|
||||||
|
if recursiveWildcard && !(strings.HasSuffix(filter, ".") || filter == "") {
|
||||||
|
return "", fmt.Errorf("only '**' or '.**' is supported as recursive wildcard in a filter")
|
||||||
|
}
|
||||||
|
|
||||||
if strings.ContainsRune(filter, '*') {
|
if strings.ContainsRune(filter, '*') {
|
||||||
return "", fmt.Errorf("'*' is only supported as the last character in a filter")
|
return "", fmt.Errorf("'*' is only supported as the last character in a filter")
|
||||||
@@ -121,7 +131,7 @@ func jacocoFilterToSpec(filter string) (string, error) {
|
|||||||
|
|
||||||
if recursiveWildcard {
|
if recursiveWildcard {
|
||||||
spec += "**/*.class"
|
spec += "**/*.class"
|
||||||
} else if wildcard {
|
} else if nonRecursiveWildcard {
|
||||||
spec += "*.class"
|
spec += "*.class"
|
||||||
} else {
|
} else {
|
||||||
spec += ".class"
|
spec += ".class"
|
||||||
|
@@ -33,13 +33,23 @@ func TestJacocoFilterToSpecs(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "package wildcard",
|
name: "package wildcard",
|
||||||
in: "package.*",
|
in: "package.*",
|
||||||
|
out: "package/*.class",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "package recursive wildcard",
|
||||||
|
in: "package.**",
|
||||||
out: "package/**/*.class",
|
out: "package/**/*.class",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "all wildcard",
|
name: "recursive wildcard only",
|
||||||
in: "*",
|
in: "**",
|
||||||
out: "**/*.class",
|
out: "**/*.class",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "single wildcard only",
|
||||||
|
in: "*",
|
||||||
|
out: "*.class",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
Reference in New Issue
Block a user