Refactor proto_bzl_test_suite to use a dictionary for test definitions. PiperOrigin-RevId: 900303772
diff --git a/bazel/tests/java_lite_proto_library_tests/binary_deps/tests.bzl b/bazel/tests/java_lite_proto_library_tests/binary_deps/tests.bzl index 97971b3..95bc44b 100644 --- a/bazel/tests/java_lite_proto_library_tests/binary_deps/tests.bzl +++ b/bazel/tests/java_lite_proto_library_tests/binary_deps/tests.bzl
@@ -25,4 +25,6 @@ "java/core/liblite_runtime_only-hjar.jar", ]) -TESTS = [(_test_binary_deps, ":foo_java_proto_lite")] +TESTS = { + ":foo_java_proto_lite": [_test_binary_deps], +}
diff --git a/bazel/tests/java_lite_proto_library_tests/binary_option_deps/tests.bzl b/bazel/tests/java_lite_proto_library_tests/binary_option_deps/tests.bzl index 6e903e9..84a8784 100644 --- a/bazel/tests/java_lite_proto_library_tests/binary_option_deps/tests.bzl +++ b/bazel/tests/java_lite_proto_library_tests/binary_option_deps/tests.bzl
@@ -23,4 +23,6 @@ "java/core/liblite_runtime_only-hjar.jar", ]) -TESTS = [(_test_binary_option_deps, ":foo_java_proto_lite")] +TESTS = { + ":foo_java_proto_lite": [_test_binary_option_deps], +}
diff --git a/bazel/tests/java_lite_proto_library_tests/command_line_contains_target_label/tests.bzl b/bazel/tests/java_lite_proto_library_tests/command_line_contains_target_label/tests.bzl index f1d2259..c0d75f7 100644 --- a/bazel/tests/java_lite_proto_library_tests/command_line_contains_target_label/tests.bzl +++ b/bazel/tests/java_lite_proto_library_tests/command_line_contains_target_label/tests.bzl
@@ -9,4 +9,6 @@ "java_lite_proto_library", ]).in_order() -TESTS = [(_test_lite_command_line_contains_target_label, ":foo_proto")] +TESTS = { + ":foo_proto": [_test_lite_command_line_contains_target_label], +}
diff --git a/bazel/tests/java_lite_proto_library_tests/compiler_args/tests.bzl b/bazel/tests/java_lite_proto_library_tests/compiler_args/tests.bzl index a0bd1b0..2daf7ca 100644 --- a/bazel/tests/java_lite_proto_library_tests/compiler_args/tests.bzl +++ b/bazel/tests/java_lite_proto_library_tests/compiler_args/tests.bzl
@@ -9,4 +9,6 @@ "{package}/foo.proto", ]).in_order() -TESTS = [(_test_lite_java_proto2_compiler_args, ":foo_proto")] +TESTS = { + ":foo_proto": [_test_lite_java_proto2_compiler_args], +}
diff --git a/bazel/tests/java_lite_proto_library_tests/proto_library_builds_compiled_jar/tests.bzl b/bazel/tests/java_lite_proto_library_tests/proto_library_builds_compiled_jar/tests.bzl index 07e9fc1..0b858e3 100644 --- a/bazel/tests/java_lite_proto_library_tests/proto_library_builds_compiled_jar/tests.bzl +++ b/bazel/tests/java_lite_proto_library_tests/proto_library_builds_compiled_jar/tests.bzl
@@ -5,4 +5,6 @@ "{package}/libfoo_proto-lite.jar", ) -TESTS = [(_test_lite_proto_library_builds_compiled_jar, ":foo_java_proto_lite")] +TESTS = { + ":foo_java_proto_lite": [_test_lite_proto_library_builds_compiled_jar], +}
diff --git a/bazel/tests/java_lite_proto_library_tests/same_version_compiler_arguments/tests.bzl b/bazel/tests/java_lite_proto_library_tests/same_version_compiler_arguments/tests.bzl index fcfa623..59bb953 100644 --- a/bazel/tests/java_lite_proto_library_tests/same_version_compiler_arguments/tests.bzl +++ b/bazel/tests/java_lite_proto_library_tests/same_version_compiler_arguments/tests.bzl
@@ -18,4 +18,6 @@ "java/core/liblite_runtime_only.jar", ]) -TESTS = [(_test_same_version_compiler_arguments, ":baz_proto")] +TESTS = { + ":baz_proto": [_test_same_version_compiler_arguments], +}
diff --git a/bazel/tests/proto_bzl_test_suite.bzl b/bazel/tests/proto_bzl_test_suite.bzl index 9e6f286..618b979 100644 --- a/bazel/tests/proto_bzl_test_suite.bzl +++ b/bazel/tests/proto_bzl_test_suite.bzl
@@ -22,27 +22,30 @@ """Defines a test suite for bzl analysis tests. Args: - tests: A list of tuples, where each tuple contains an analysis test - implementation function and a target to test. - config_settings: A dictionary of config settings to apply to the test suite. - testing_aspect: The testing aspect to use. name: The name of the test suite. + tests: A dictionary where the key is the build target and the value is a list of + analysis test implementation functions using that target. + attrs: A dictionary of attributes to apply to the testing aspect. + testing_aspect: The testing aspect to use in the test suite. + provider_subject_factories: An array of subject factories to use in the test suite. + config_settings: A dictionary of config settings to apply to the test suite. """ test_names = [] - for (impl, target) in tests: - impl_name = get_function_name(impl) - test_name = create_test_name(impl_name, name) - analysis_test( - name = test_name, - target = target, - impl = impl, - provider_subject_factories = provider_subject_factories, - config_settings = config_settings, - testing_aspect = testing_aspect, - attrs = attrs, - ) - test_names.append(test_name) + for target, impl_list in tests.items(): + for impl in impl_list: + impl_name = get_function_name(impl) + test_name = create_test_name(impl_name, name) + analysis_test( + name = test_name, + target = target, + impl = impl, + provider_subject_factories = provider_subject_factories, + config_settings = config_settings, + testing_aspect = testing_aspect, + attrs = attrs, + ) + test_names.append(test_name) native.test_suite( name = name,
diff --git a/bazel/tests/py_proto_library_tests/collects_python_files_from_deps_when_srcs_is_empty/tests.bzl b/bazel/tests/py_proto_library_tests/collects_python_files_from_deps_when_srcs_is_empty/tests.bzl index bd402ff..c8f0d5c 100644 --- a/bazel/tests/py_proto_library_tests/collects_python_files_from_deps_when_srcs_is_empty/tests.bzl +++ b/bazel/tests/py_proto_library_tests/collects_python_files_from_deps_when_srcs_is_empty/tests.bzl
@@ -6,6 +6,6 @@ expected_basename = "b_pb2.py" env.expect.that_collection(runfiles_paths).contains(expected_basename) -TESTS = [ - (test_collects_python_files_from_deps_when_srcs_is_empty, ":a_py_pb2"), -] +TESTS = { + ":a_py_pb2": [test_collects_python_files_from_deps_when_srcs_is_empty], +}
diff --git a/bazel/tests/py_proto_library_tests/python_proto2_deps/tests.bzl b/bazel/tests/py_proto_library_tests/python_proto2_deps/tests.bzl index 7729465..1bfb8f0 100644 --- a/bazel/tests/py_proto_library_tests/python_proto2_deps/tests.bzl +++ b/bazel/tests/py_proto_library_tests/python_proto2_deps/tests.bzl
@@ -5,6 +5,6 @@ env.expect.that_collection(runfiles_paths).contains("message.py") -TESTS = [ - (_test_python_proto2_deps, ":proto2_deps_bin"), -] +TESTS = { + ":proto2_deps_bin": [_test_python_proto2_deps], +}