Merge "Sort genrule allowlists" into main
diff --git a/java/droidstubs.go b/java/droidstubs.go
index b059c0a..5432ce7 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -538,7 +538,9 @@
// Force metalava to sort overloaded methods by their order in the source code.
// See b/285312164 for more information.
- cmd.FlagWithArg("--format-defaults ", "overloaded-method-order=source")
+ // And add concrete overrides of abstract methods, see b/299366704 for more
+ // information.
+ cmd.FlagWithArg("--format-defaults ", "overloaded-method-order=source,add-additional-overrides=yes")
if ctx.DeviceConfig().HideFlaggedApis() {
cmd.FlagWithArg("--hide-annotation ", "android.annotation.FlaggedApi")
diff --git a/java/testing.go b/java/testing.go
index 0b7e685..4461351 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -73,10 +73,15 @@
// Needed for various deps defined in GatherRequiredDepsForTest()
defaultJavaDir + "/a.java": nil,
defaultJavaDir + "/api/current.txt": nil,
+ defaultJavaDir + "/api/removed.txt": nil,
defaultJavaDir + "/api/system-current.txt": nil,
+ defaultJavaDir + "/api/system-removed.txt": nil,
defaultJavaDir + "/api/test-current.txt": nil,
+ defaultJavaDir + "/api/test-removed.txt": nil,
defaultJavaDir + "/api/module-lib-current.txt": nil,
+ defaultJavaDir + "/api/module-lib-removed.txt": nil,
defaultJavaDir + "/api/system-server-current.txt": nil,
+ defaultJavaDir + "/api/system-server-removed.txt": nil,
// Needed for R8 rules on apps
"build/make/core/proguard.flags": nil,
@@ -425,80 +430,96 @@
`, extra)
}
- type apiContributionStruct struct {
- name string
- apiSurface string
- apiFile string
+ type droidstubsStruct struct {
+ name string
+ apiSurface string
+ apiFile string
+ removedFile string
}
- var publicApiContribution = apiContributionStruct{
- name: "api-stubs-docs-non-updatable.api.contribution",
- apiSurface: "public",
- apiFile: "api/current.txt",
+ var publicDroidstubs = droidstubsStruct{
+ name: "api-stubs-docs-non-updatable",
+ apiSurface: "public",
+ apiFile: "api/current.txt",
+ removedFile: "api/removed.txt",
}
- var systemApiContribution = apiContributionStruct{
- name: "system-api-stubs-docs-non-updatable.api.contribution",
- apiSurface: "system",
- apiFile: "api/system-current.txt",
+ var systemDroidstubs = droidstubsStruct{
+ name: "system-api-stubs-docs-non-updatable",
+ apiSurface: "system",
+ apiFile: "api/system-current.txt",
+ removedFile: "api/system-removed.txt",
}
- var testApiContribution = apiContributionStruct{
- name: "test-api-stubs-docs-non-updatable.api.contribution",
- apiSurface: "test",
- apiFile: "api/test-current.txt",
+ var testDroidstubs = droidstubsStruct{
+ name: "test-api-stubs-docs-non-updatable",
+ apiSurface: "test",
+ apiFile: "api/test-current.txt",
+ removedFile: "api/test-removed.txt",
}
- var moduleLibApiContribution = apiContributionStruct{
- name: "module-lib-api-stubs-docs-non-updatable.api.contribution",
- apiSurface: "module-lib",
- apiFile: "api/module-lib-current.txt",
+ var moduleLibDroidstubs = droidstubsStruct{
+ name: "module-lib-api-stubs-docs-non-updatable",
+ apiSurface: "module-lib",
+ apiFile: "api/module-lib-current.txt",
+ removedFile: "api/module-lib-removed.txt",
}
- var systemServerApiContribution = apiContributionStruct{
+ var systemServerDroidstubs = droidstubsStruct{
// This module does not exist but is named this way for consistency
- name: "system-server-api-stubs-docs-non-updatable.api.contribution",
- apiSurface: "system-server",
- apiFile: "api/system-server-current.txt",
+ name: "system-server-api-stubs-docs-non-updatable",
+ apiSurface: "system-server",
+ apiFile: "api/system-server-current.txt",
+ removedFile: "api/system-server-removed.txt",
}
- var apiContributionStructs = []apiContributionStruct{
- publicApiContribution,
- systemApiContribution,
- testApiContribution,
- moduleLibApiContribution,
- systemServerApiContribution,
+ var droidstubsStructs = []droidstubsStruct{
+ publicDroidstubs,
+ systemDroidstubs,
+ testDroidstubs,
+ moduleLibDroidstubs,
+ systemServerDroidstubs,
}
- extraApiLibraryModules := map[string]apiContributionStruct{
- "android_stubs_current.from-text": publicApiContribution,
- "android_system_stubs_current.from-text": systemApiContribution,
- "android_test_stubs_current.from-text": testApiContribution,
- "android_module_lib_stubs_current.from-text": moduleLibApiContribution,
- "android_module_lib_stubs_current_full.from-text": moduleLibApiContribution,
- "android_system_server_stubs_current.from-text": systemServerApiContribution,
- "core.current.stubs.from-text": publicApiContribution,
- "legacy.core.platform.api.stubs.from-text": publicApiContribution,
- "stable.core.platform.api.stubs.from-text": publicApiContribution,
- "core-lambda-stubs.from-text": publicApiContribution,
- "android-non-updatable.stubs.from-text": publicApiContribution,
- "android-non-updatable.stubs.system.from-text": systemApiContribution,
- "android-non-updatable.stubs.test.from-text": testApiContribution,
- "android-non-updatable.stubs.module_lib.from-text": moduleLibApiContribution,
+ extraApiLibraryModules := map[string]droidstubsStruct{
+ "android_stubs_current.from-text": publicDroidstubs,
+ "android_system_stubs_current.from-text": systemDroidstubs,
+ "android_test_stubs_current.from-text": testDroidstubs,
+ "android_module_lib_stubs_current.from-text": moduleLibDroidstubs,
+ "android_module_lib_stubs_current_full.from-text": moduleLibDroidstubs,
+ "android_system_server_stubs_current.from-text": systemServerDroidstubs,
+ "core.current.stubs.from-text": publicDroidstubs,
+ "legacy.core.platform.api.stubs.from-text": publicDroidstubs,
+ "stable.core.platform.api.stubs.from-text": publicDroidstubs,
+ "core-lambda-stubs.from-text": publicDroidstubs,
+ "android-non-updatable.stubs.from-text": publicDroidstubs,
+ "android-non-updatable.stubs.system.from-text": systemDroidstubs,
+ "android-non-updatable.stubs.test.from-text": testDroidstubs,
+ "android-non-updatable.stubs.module_lib.from-text": moduleLibDroidstubs,
}
- for _, apiContribution := range apiContributionStructs {
+ for _, droidstubs := range droidstubsStructs {
bp += fmt.Sprintf(`
- java_api_contribution {
+ droidstubs {
name: "%s",
api_surface: "%s",
- api_file: "%s",
+ check_api: {
+ current: {
+ api_file: "%s",
+ removed_api_file: "%s",
+ }
+ }
}
- `, apiContribution.name, apiContribution.apiSurface, apiContribution.apiFile)
+ `,
+ droidstubs.name,
+ droidstubs.apiSurface,
+ droidstubs.apiFile,
+ droidstubs.removedFile,
+ )
}
- for libName, apiContribution := range extraApiLibraryModules {
+ for libName, droidstubs := range extraApiLibraryModules {
bp += fmt.Sprintf(`
java_api_library {
name: "%s",
api_contributions: ["%s"],
}
- `, libName, apiContribution.name)
+ `, libName, droidstubs.name+".api.contribution")
}
bp += `
@@ -553,7 +574,7 @@
return bp
}
-func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string, expected []string) {
+func getModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string) []string {
t.Helper()
module := ctx.ModuleForTests(name, variant).Module()
deps := []string{}
@@ -562,11 +583,29 @@
})
sort.Strings(deps)
+ return deps
+}
+
+// CheckModuleDependencies checks if the expected dependencies of the module are
+// identical to the actual dependencies.
+func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string, expected []string) {
+ deps := getModuleDependencies(t, ctx, name, variant)
+
if actual := deps; !reflect.DeepEqual(expected, actual) {
t.Errorf("expected %#q, found %#q", expected, actual)
}
}
+// CheckModuleHasDependency returns true if the module depends on the expected dependency.
+func CheckModuleHasDependency(t *testing.T, ctx *android.TestContext, name, variant string, expected string) bool {
+ for _, dep := range getModuleDependencies(t, ctx, name, variant) {
+ if dep == expected {
+ return true
+ }
+ }
+ return false
+}
+
// CheckPlatformBootclasspathModules returns the apex:module pair for the modules depended upon by
// the platform-bootclasspath module.
func CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, name string, expected []string) {
diff --git a/tests/b_args_test.sh b/tests/b_args_test.sh
new file mode 100755
index 0000000..0dfbabf
--- /dev/null
+++ b/tests/b_args_test.sh
@@ -0,0 +1,43 @@
+#!/bin/bash -eu
+
+# This file tests the creation of bazel commands for b usage
+set -o pipefail
+source "$(dirname "$0")/../../bazel/lib.sh"
+
+BES_UUID="blank"
+OUT_DIR="arbitrary_out"
+b_args=$(formulate_b_args "build --config=nonsense foo:bar")
+
+if [[ $b_args != "build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=metrics_data --config=nonsense foo:bar" ]]; then
+ echo "b args are malformed"
+ echo "Expected : build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=metrics_data --config=nonsense foo:bar"
+ echo "Actual: $b_args"
+ exit 1
+fi
+
+b_args=$(formulate_b_args "build --config=nonsense --disable_bes --package_path \"my package\" foo:bar")
+
+if [[ $b_args != "build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar" ]]; then
+ echo "b args are malformed"
+ echo "Expected : build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar"
+ echo "Actual: $b_args"
+ exit 1
+fi
+
+# Test with startup option
+b_args=$(formulate_b_args "--batch build --config=nonsense --disable_bes --package_path \"my package\" foo:bar")
+if [[ $b_args != "--batch build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar" ]]; then
+ echo "b args are malformed"
+ echo "Expected : --batch build --profile=$OUT_DIR/bazel_metrics-profile --config=bp2build --invocation_id=$BES_UUID --config=nonsense --package_path \"my package\" foo:bar"
+ echo "Actual: $b_args"
+ exit 1
+fi
+
+OUT_DIR="mock_out"
+TEST_PROFILE_OUT=$(get_profile_out_dir)
+if [[ $TEST_PROFILE_OUT != "mock_out" ]]; then
+ echo "Profile Out is malformed."
+ echo "Expected: mock_out"
+ echo "Actual: $TEST_PROFILE_OUT"
+ exit 1
+fi
diff --git a/tests/lib.sh b/tests/lib.sh
index fb3b374..e0b319e 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -16,7 +16,7 @@
if [[ -n "$HARDWIRED_MOCK_TOP" ]]; then
MOCK_TOP="$HARDWIRED_MOCK_TOP"
else
- MOCK_TOP=$(mktemp -t -d st.XXXXX)
+ MOCK_TOP=$(make_mock_top)
trap cleanup_mock_top EXIT
fi
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index 8045591..231e18b 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -4,6 +4,7 @@
TOP="$(readlink -f "$(dirname "$0")"/../../..)"
"$TOP/build/soong/tests/androidmk_test.sh"
+"$TOP/build/soong/tests/b_args_test.sh"
"$TOP/build/soong/tests/bootstrap_test.sh"
"$TOP/build/soong/tests/mixed_mode_test.sh"
"$TOP/build/soong/tests/bp2build_bazel_test.sh"