diff options
author | 2025-03-12 17:03:08 -0700 | |
---|---|---|
committer | 2025-03-12 17:18:09 -0700 | |
commit | 238a3e36b90841aa4e1d5f34cc3ad560cdd6b2be (patch) | |
tree | e735032b5fcd35ad1a0d673e23be10d9a22cad58 | |
parent | 7c18e7f15b997e0e3199111446e0511ffd96b811 (diff) |
Mark "Ravenwood-tests" and "robo-test" modules as being TestOnly and top-level-tests for code coverage reporting.
Fixes: 402451184
Tests: m nothing --no-skip-soong-tests blueprint_tests
Tests: go test ./java
Tests: m all_teams && gqui from "flatten(out/soong/ownership/all_teams.pb, teams)" proto build/soong/android/team_proto/team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind'
+--------------------------+----------+
| teams.kind | count(*) |
+--------------------------+----------+
| android_ravenwood_test | 37 |
| android_robolectric_test | 118 |
| android_test | 2230 |
| android_test_helper_app | 2125 |
...
Change-Id: Ib81b6d261a3088aed44ea4d74452f99ff0f3d587
-rw-r--r-- | java/ravenwood.go | 2 | ||||
-rw-r--r-- | java/ravenwood_test.go | 11 | ||||
-rw-r--r-- | java/robolectric.go | 8 | ||||
-rw-r--r-- | java/robolectric_test.go | 11 |
4 files changed, 31 insertions, 1 deletions
diff --git a/java/ravenwood.go b/java/ravenwood.go index c4078c587..a942dc653 100644 --- a/java/ravenwood.go +++ b/java/ravenwood.go @@ -117,6 +117,8 @@ func ravenwoodTestFactory() android.Module { "ravenwood-tests", } module.testProperties.Test_options.Unit_test = proptools.BoolPtr(false) + module.Module.sourceProperties.Test_only = proptools.BoolPtr(true) + module.Module.sourceProperties.Top_level_test_target = true InitJavaModule(module, android.DeviceSupported) android.InitDefaultableModule(module) diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go index 24a02bbdc..d6493bcfa 100644 --- a/java/ravenwood_test.go +++ b/java/ravenwood_test.go @@ -230,4 +230,15 @@ func TestRavenwoodTest(t *testing.T) { android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/libred.so") android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so") android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-utils/framework-rules.ravenwood.jar") + + // Ensure they are listed as "test" modules for code coverage + expectedTestOnlyModules := []string{ + "ravenwood-test", + "ravenwood-test-empty", + } + expectedTopLevelTests := []string{ + "ravenwood-test", + "ravenwood-test-empty", + } + assertTestOnlyAndTopLevel(t, ctx, expectedTestOnlyModules, expectedTopLevelTests) } diff --git a/java/robolectric.go b/java/robolectric.go index be369f780..1d204a4e0 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -284,6 +284,11 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) android.SetProvider(ctx, android.TestSuiteInfoProvider, android.TestSuiteInfo{ TestSuites: r.TestSuites(), }) + + android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{ + TestOnly: Bool(r.sourceProperties.Test_only), + TopLevelTarget: r.sourceProperties.Top_level_test_target, + }) } func generateSameDirRoboTestConfigJar(ctx android.ModuleContext, outputFile android.ModuleOutPath) { @@ -335,7 +340,8 @@ func RobolectricTestFactory() android.Module { module.Module.dexpreopter.isTest = true module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true) - + module.Module.sourceProperties.Test_only = proptools.BoolPtr(true) + module.Module.sourceProperties.Top_level_test_target = true module.testProperties.Test_suites = []string{"robolectric-tests"} InitJavaModule(module, android.DeviceSupported) diff --git a/java/robolectric_test.go b/java/robolectric_test.go index 4bf224b4f..cc16c6a26 100644 --- a/java/robolectric_test.go +++ b/java/robolectric_test.go @@ -107,4 +107,15 @@ func TestRobolectricJniTest(t *testing.T) { // Check that the .so files make it into the output. module := ctx.ModuleForTests(t, "robo-test", "android_common") module.Output(installPathPrefix + "/robo-test/lib64/jni-lib1.so") + + // Ensure they are listed as "test" modules for code coverage + expectedTestOnlyModules := []string{ + "robo-test", + } + + expectedTopLevelTests := []string{ + "robo-test", + } + assertTestOnlyAndTopLevel(t, ctx, expectedTestOnlyModules, expectedTopLevelTests) + } |