diff options
author | 2020-06-24 20:36:59 +0000 | |
---|---|---|
committer | 2020-06-25 16:45:44 +0000 | |
commit | 2f748692dd0ebdd9677b44f43e8a49f042727db2 (patch) | |
tree | 29ad0bd842be18c6f032f5804a261a9a9a1fd985 /java | |
parent | 6f61fa75c676268851d2a1cf433f26c042a62939 (diff) |
Use a default exclude filter for JaCoCo in Soong.
Instrumented builds should exclude certain classes from instrumenation
by default. (e.g. JaCoCo itself) Leverage the existing
DefaultJacocoExclusionFilter to do this.
Note: Two different default filters exist now (one for Make and one for
Soong), as they have different wildcard rules.
Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true m -j32
TeleService and inspected the resulting temporary jar that was
instrumented to confirm that anything from org/jacoco was excluded.
Bug: 159748844
Change-Id: I5466b0a03957edfbe53971d5d1a7729fdb8337db
Diffstat (limited to 'java')
-rw-r--r-- | java/config/config.go | 3 | ||||
-rw-r--r-- | java/config/makevars.go | 2 | ||||
-rw-r--r-- | java/jacoco.go | 4 |
3 files changed, 6 insertions, 3 deletions
diff --git a/java/config/config.go b/java/config/config.go index bb5be3aca..23b593a82 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -35,7 +35,8 @@ var ( DefaultLambdaStubsLibrary = "core-lambda-stubs" SdkLambdaStubsPath = "prebuilts/sdk/tools/core-lambda-stubs.jar" - DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"} + DefaultMakeJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"} + DefaultJacocoExcludeFilter = []string{"org.junit.**", "org.jacoco.**", "org.mockito.**"} InstrumentFrameworkModules = []string{ "framework", diff --git a/java/config/makevars.go b/java/config/makevars.go index 981a73638..b355fad87 100644 --- a/java/config/makevars.go +++ b/java/config/makevars.go @@ -64,7 +64,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) { ctx.Strict("ZIPSYNC", "${ZipSyncCmd}") ctx.Strict("JACOCO_CLI_JAR", "${JacocoCLIJar}") - ctx.Strict("DEFAULT_JACOCO_EXCLUDE_FILTER", strings.Join(DefaultJacocoExcludeFilter, ",")) + ctx.Strict("DEFAULT_JACOCO_EXCLUDE_FILTER", strings.Join(DefaultMakeJacocoExcludeFilter, ",")) ctx.Strict("EXTRACT_JAR_PACKAGES", "${ExtractJarPackagesCmd}") diff --git a/java/jacoco.go b/java/jacoco.go index bce9822f4..9162161d3 100644 --- a/java/jacoco.go +++ b/java/jacoco.go @@ -25,6 +25,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/java/config" ) var ( @@ -76,7 +77,8 @@ func (j *Module) jacocoModuleToZipCommand(ctx android.ModuleContext) string { if err != nil { ctx.PropertyErrorf("jacoco.include_filter", "%s", err.Error()) } - excludes, err := jacocoFiltersToSpecs(j.properties.Jacoco.Exclude_filter) + // Also include the default list of classes to exclude from instrumentation. + excludes, err := jacocoFiltersToSpecs(append(j.properties.Jacoco.Exclude_filter, config.DefaultJacocoExcludeFilter...)) if err != nil { ctx.PropertyErrorf("jacoco.exclude_filter", "%s", err.Error()) } |