Merge "Change the syntax for jacoco filter wildcard parameters."
This commit is contained in:
commit
19b4555593
2 changed files with 27 additions and 7 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
|
@ -105,13 +106,22 @@ func jacocoFiltersToSpecs(filters []string) ([]string, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
return specs, nil
|
||||
return proptools.NinjaAndShellEscape(specs), nil
|
||||
}
|
||||
|
||||
func jacocoFilterToSpec(filter string) (string, error) {
|
||||
wildcard := strings.HasSuffix(filter, "*")
|
||||
filter = strings.TrimSuffix(filter, "*")
|
||||
recursiveWildcard := wildcard && (strings.HasSuffix(filter, ".") || filter == "")
|
||||
recursiveWildcard := strings.HasSuffix(filter, "**")
|
||||
nonRecursiveWildcard := false
|
||||
if !recursiveWildcard {
|
||||
nonRecursiveWildcard = strings.HasSuffix(filter, "*")
|
||||
filter = strings.TrimSuffix(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, '*') {
|
||||
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 {
|
||||
spec += "**/*.class"
|
||||
} else if wildcard {
|
||||
} else if nonRecursiveWildcard {
|
||||
spec += "*.class"
|
||||
} else {
|
||||
spec += ".class"
|
||||
|
|
|
@ -33,13 +33,23 @@ func TestJacocoFilterToSpecs(t *testing.T) {
|
|||
{
|
||||
name: "package wildcard",
|
||||
in: "package.*",
|
||||
out: "package/*.class",
|
||||
},
|
||||
{
|
||||
name: "package recursive wildcard",
|
||||
in: "package.**",
|
||||
out: "package/**/*.class",
|
||||
},
|
||||
{
|
||||
name: "all wildcard",
|
||||
in: "*",
|
||||
name: "recursive wildcard only",
|
||||
in: "**",
|
||||
out: "**/*.class",
|
||||
},
|
||||
{
|
||||
name: "single wildcard only",
|
||||
in: "*",
|
||||
out: "*.class",
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
|
Loading…
Reference in a new issue