Migrate the `JavaImportConfiguredTargetTest.testDisallowsArbitraryFiles` test to Starlark The test is removed from Bazel and added to rules_java (ignore-relnotes) PiperOrigin-RevId: 756265386 Change-Id: Ib9756b4bb3b4bef372f344ad6c11b9593e60f9a1
diff --git a/test/java/common/rules/java_import_tests.bzl b/test/java/common/rules/java_import_tests.bzl index 064c59a..b865c76 100644 --- a/test/java/common/rules/java_import_tests.bzl +++ b/test/java/common/rules/java_import_tests.bzl
@@ -493,6 +493,25 @@ matching.str_matches("source file * is misplaced here (expected no files)"), ) +def _test_disallows_arbitrary_files(name): + util.helper_target( + java_import, + name = name + "/rule", + jars = ["not-a-jar.txt"], + ) + + analysis_test( + name = name, + impl = _test_disallows_arbitrary_files_impl, + target = name + "/rule", + expect_failure = True, + ) + +def _test_disallows_arbitrary_files_impl(env, target): + env.expect.that_target(target).failures().contains_predicate( + matching.str_matches("does not produce any java_import jars files (expected .jar)"), + ) + def java_import_tests(name): test_suite( name = name, @@ -512,5 +531,6 @@ _test_permits_empty_jars_with_flag, _test_disallows_empty_jars, _test_disallows_files_in_exports, + _test_disallows_arbitrary_files, ], )