diff options
author | Paul Duffin <paulduffin@google.com> | 2021-04-23 13:55:49 +0100 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2021-04-26 17:22:28 +0100 |
commit | c7d1644b0bc5281c8f1a6c19bb071527e7628b9f (patch) | |
tree | 03816a7c9929a92df5336abe6747f7e6473cff6d /java/bootclasspath_fragment_test.go | |
parent | 46e4a9e6b189ceec44157fa0e0602cdfd39078cd (diff) |
Add coverage specific properties to bootclasspath_fragment
This allows a bootclasspath_fragment (specifically the
art-bootclasspath-fragment) to specify additional contents to be
appended when coverage is enabled.
The art-bootclasspath-fragment will use this to add jacocoagent to its
contents to ensure that it is always consistent with the configuration.
Bug: 177892522
Test: m nothing
Change-Id: I50d05fe5e0e9b8c14bdf3dfd63bba0ac97e31d48
Diffstat (limited to 'java/bootclasspath_fragment_test.go')
-rw-r--r-- | java/bootclasspath_fragment_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go index 524a2269b..0db93619c 100644 --- a/java/bootclasspath_fragment_test.go +++ b/java/bootclasspath_fragment_test.go @@ -125,3 +125,62 @@ func TestBootclasspathFragmentWithImageNameAndContents(t *testing.T) { } `) } + +func TestBootclasspathFragment_Coverage(t *testing.T) { + prepareForTestWithFrameworkCoverage := android.FixtureMergeEnv(map[string]string{ + "EMMA_INSTRUMENT": "true", + "EMMA_INSTRUMENT_FRAMEWORK": "true", + }) + + prepareWithBp := android.FixtureWithRootAndroidBp(` + bootclasspath_fragment { + name: "myfragment", + contents: [ + "mybootlib", + ], + coverage: { + contents: [ + "coveragelib", + ], + }, + } + + java_library { + name: "mybootlib", + srcs: ["Test.java"], + system_modules: "none", + sdk_version: "none", + compile_dex: true, + } + + java_library { + name: "coveragelib", + srcs: ["Test.java"], + system_modules: "none", + sdk_version: "none", + compile_dex: true, + } + `) + + checkContents := func(t *testing.T, result *android.TestResult, expected ...string) { + module := result.Module("myfragment", "android_common").(*BootclasspathFragmentModule) + android.AssertArrayString(t, "contents property", expected, module.properties.Contents) + } + + t.Run("without coverage", func(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForTestWithBootclasspathFragment, + prepareWithBp, + ).RunTest(t) + checkContents(t, result, "mybootlib") + }) + + t.Run("with coverage", func(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForTestWithBootclasspathFragment, + prepareForTestWithFrameworkCoverage, + prepareWithBp, + ).RunTest(t) + checkContents(t, result, "mybootlib", "coveragelib") + }) +} |