Merge #551 by ted-xie: Follow-up implicit output test for #547 #547 modified the R8 rule's implicit outputs. This change adds an analysis test to verify that change. Closes #551 COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_android/pull/551 from ted-xie:r8-implicit-output-unit-test fea296054d7d38d3ea3d26d2116bdf8f47f7e966 PiperOrigin-RevId: 975249246 Change-Id: I85c93afb5ddebd0b81f1f613c10a52a38de70bb4
diff --git a/test/rules/android_binary/r8_integration/BUILD b/test/rules/android_binary/r8_integration/BUILD index 413446e..7e444a5 100644 --- a/test/rules/android_binary/r8_integration/BUILD +++ b/test/rules/android_binary/r8_integration/BUILD
@@ -6,7 +6,7 @@ ) load("@rules_python//python:py_test.bzl", "py_test") load("@rules_shell//shell:sh_library.bzl", "sh_library") -load(":test.bzl", "r8_neverlink_deps_test") +load(":test.bzl", "r8_implicit_outputs_test", "r8_neverlink_deps_test") py_test( name = "r8_integration_test", @@ -21,6 +21,11 @@ ], ) +r8_implicit_outputs_test( + name = "r8_implicit_outputs_test", + target_under_test = "//test/rules/android_binary/r8_integration/java/com/neverlink:android_binary_with_neverlink_deps", +) + r8_neverlink_deps_test( name = "r8_neverlink_deps_test", target_under_test = "//test/rules/android_binary/r8_integration/java/com/neverlink:android_binary_with_neverlink_deps",
diff --git a/test/rules/android_binary/r8_integration/test.bzl b/test/rules/android_binary/r8_integration/test.bzl index 3270474..1bbe6f2 100644 --- a/test/rules/android_binary/r8_integration/test.bzl +++ b/test/rules/android_binary/r8_integration/test.bzl
@@ -55,3 +55,29 @@ r8_neverlink_deps_test = analysistest.make( impl = r8_neverlink_deps_test_impl, ) + +def r8_implicit_outputs_test_impl(ctx): + """Tests that R8 declares proguard_mappings_output_file as implicit_outputs. + + Args: + ctx: The ctx. + + Returns: + The providers. + """ + env = analysistest.begin(ctx) + target = analysistest.target_under_test(env) + + default_files = [f.basename for f in target[DefaultInfo].files.to_list()] + expected_map = target.label.name + "_proguard.map" + asserts.true( + env, + expected_map in default_files, + "Expected %s to be in default outputs %s" % (expected_map, default_files), + ) + + return analysistest.end(env) + +r8_implicit_outputs_test = analysistest.make( + impl = r8_implicit_outputs_test_impl, +)