summaryrefslogtreecommitdiff
path: root/java/droidstubs_test.go
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2023-12-19 01:13:16 +0000
committer Jihoon Kang <jihoonkang@google.com> 2024-01-08 07:55:49 +0000
commit6592e87dbfe1e49b5c57ca8ead0bb48e6354e261 (patch)
tree6a5ff7da0e16b8fbaf62b3b29811c531c3260568 /java/droidstubs_test.go
parent98aa78ab22e04a26af9ff39a39d9ecfdea5fb845 (diff)
Add aconfig_declarations property to droidstubs and java_sdk_library
In consideration of the incremental build performance, this change let droidstubs and java_sdk_library (which generates droidstubs per api scope) modules to specify `aconfig_declaration` modules where the dependent flags are defined in via the "aconfig_declarations" property, opposed to passing uniform "all_aconfig_declaration"-generated flag arguments to metalava. When "aconfig_declarations" property is defined for java_sdk_library modules, the property is passed to the generated droidstubs modules. When "aconfig_declarations" property is defined for droidstubs modules, the all aconfig_declaration modules listed in the property are listed as deps, all cache protobuf files are gathered and metalava-consumable flags are generated in "revert-annotations.txt". Although this change introduces scalable implementation to easily support generation of the "runtime" stubs corresponding flags, actual support of the runtime flags/stubs will be done in future changes. This change mostly focuses on the generation of the "exportable" flags. Utilization of the generated "exportable" flags will be done in future changes. Test: go test ./java Bug: 315485740 Change-Id: I37becd1b9dd9069d7ac4abed130906df30b3fdf4
Diffstat (limited to 'java/droidstubs_test.go')
-rw-r--r--java/droidstubs_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 7bcaca1d4..5544890af 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -395,3 +395,46 @@ func TestDroidstubsHideFlaggedApi(t *testing.T) {
cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "--revert-annotation android.annotation.FlaggedApi")
}
+
+func TestAconfigDeclarations(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ }),
+ android.FixtureMergeMockFs(map[string][]byte{
+ "a/A.java": nil,
+ "a/current.txt": nil,
+ "a/removed.txt": nil,
+ }),
+ ).RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "bar",
+ package: "com.example.package",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ droidstubs {
+ name: "foo",
+ srcs: ["a/A.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "a/current.txt",
+ removed_api_file: "a/removed.txt",
+ }
+ },
+ aconfig_declarations: [
+ "bar",
+ ],
+ }
+ `)
+
+ // Check that droidstubs depend on aconfig_declarations
+ android.AssertBoolEquals(t, "foo expected to depend on bar",
+ CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true)
+
+ m := result.ModuleForTests("foo", "android_common")
+ android.AssertStringDoesContain(t, "foo generates revert annotations file",
+ strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt")
+}