diff options
author | 2024-09-26 14:06:24 +0000 | |
---|---|---|
committer | 2024-09-26 14:06:24 +0000 | |
commit | ad95b9b84ad2476f1123a0bf5ad710aebb2a2b92 (patch) | |
tree | 0ea3d3e6fa19869046c84aaee5b632271ac10998 /java/java_test.go | |
parent | 6a87686c6b3d8cbee8a12c3ef8060978d931ebdc (diff) | |
parent | b323c9112e5dd65a7e302d9a4e7d2a3e05bdc611 (diff) |
Merge "Fix coverage when transitive jars are enabled" into main
Diffstat (limited to 'java/java_test.go')
-rw-r--r-- | java/java_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go index e0fd0f24e..641bf4030 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -3065,6 +3065,43 @@ func TestJavaLibraryOutputFilesRel(t *testing.T) { "baz.jar", bazOutputPaths[0].Rel()) } +func TestCoverage(t *testing.T) { + result := android.GroupFixturePreparers( + PrepareForTestWithJavaDefaultModules, + prepareForTestWithFrameworkJacocoInstrumentation, + PrepareForTestWithTransitiveClasspathEnabled, + ).RunTestWithBp(t, ` + android_app { + name: "foo", + srcs: ["foo.java"], + static_libs: ["android.car"], + platform_apis: true, + } + + // A library in InstrumentFrameworkModules + java_library { + name: "android.car", + srcs: ["android.car.java"], + } + `) + + foo := result.ModuleForTests("foo", "android_common") + androidCar := result.ModuleForTests("android.car", "android_common") + + fooJacoco := foo.Rule("jacoco") + fooCombine := foo.Description("for javac") + + androidCarJacoco := androidCar.Rule("jacoco") + androidCarJavac := androidCar.Rule("javac") + + android.AssertStringEquals(t, "foo instrumentation rule inputs", fooJacoco.Input.String(), fooCombine.Output.String()) + android.AssertStringEquals(t, "android.car instrumentation rule inputs", androidCarJacoco.Input.String(), androidCarJavac.Output.String()) + + // The input to instrumentation for the `foo` app contains the non-instrumented android.car classes. + android.AssertStringListContains(t, "foo combined inputs", fooCombine.Inputs.Strings(), androidCarJavac.Output.String()) + android.AssertStringListDoesNotContain(t, "foo combined inputs", fooCombine.Inputs.Strings(), androidCarJacoco.Output.String()) +} + func assertTestOnlyAndTopLevel(t *testing.T, ctx *android.TestResult, expectedTestOnly []string, expectedTopLevel []string) { t.Helper() actualTrueModules := []string{} |