Migrate StarlarkCcToolchainConfigureTest to Starlark in rules_cc. `StarlarkCcToolchainConfigureTest` only tests the pure Starlark `split_escaped` helper in `cc/private/toolchain/lib_cc_configure.bzl` by loading the file via `ResourceLoader` into `BazelEvaluationTestCase`. Move the `testSplitEscaped` test cases (deduplicating the repeated `'a%%b'` case) into a `rules_testing` unit test in `tests/cc/common/lib_cc_configure_test.bzl` and delete `StarlarkCcToolchainConfigureTest.java` and its `java_test` target. PiperOrigin-RevId: 1029015326 Change-Id: I20992747f8666f3afa057e8488c1d2baf022c1d0
diff --git a/tests/cc/common/BUILD b/tests/cc/common/BUILD index 6eef6ef..a5be68b 100644 --- a/tests/cc/common/BUILD +++ b/tests/cc/common/BUILD
@@ -18,6 +18,7 @@ load(":debug_info_packaging_test.bzl", "debug_info_packaging_tests") load(":disallowed_copts_test.bzl", "disallowed_copts_tests") load(":find_cc_toolchain_test.bzl", "find_cc_toolchain_missing_provider_test") +load(":lib_cc_configure_test.bzl", "lib_cc_configure_tests") load(":link_build_variables_test.bzl", "link_build_variables_tests") cc_binary_configured_target_tests(name = "cc_binary_configured_target_tests") @@ -61,3 +62,5 @@ cc_binary_fdo_tests(name = "cc_binary_fdo_tests") cc_toolchain_include_directories_tests(name = "cc_toolchain_include_directories_tests") + +lib_cc_configure_tests(name = "lib_cc_configure_tests")
diff --git a/tests/cc/common/lib_cc_configure_test.bzl b/tests/cc/common/lib_cc_configure_test.bzl new file mode 100644 index 0000000..1de9f01 --- /dev/null +++ b/tests/cc/common/lib_cc_configure_test.bzl
@@ -0,0 +1,43 @@ +"""Tests for lib_cc_configure.bzl.""" + +load("@rules_testing//lib:test_suite.bzl", "test_suite") +load("//cc/private/toolchain:lib_cc_configure.bzl", "split_escaped") # buildifier: disable=bzl-visibility + +def _test_split_escaped(env): + cases = [ + ("a:b:c", ["a", "b", "c"]), + ("a%:b", ["a:b"]), + ("a%%b", ["a%b"]), + ("a:::b", ["a", "", "", "b"]), + ("a:b%:c", ["a", "b:c"]), + ("a%%:b:c", ["a%", "b", "c"]), + (":a", ["", "a"]), + ("a:", ["a", ""]), + ("::a::", ["", "", "a", "", ""]), + ("%%%:a%%%%:b", ["%:a%%", "b"]), + ("", []), + ("%", ["%"]), + ("%%", ["%"]), + ("%:", [":"]), + (":", ["", ""]), + ("a%:", ["a:"]), + ] + for string, expected in cases: + env.expect.where( + input = repr(string), + ).that_collection( + split_escaped(string, ":"), + ).contains_exactly(expected).in_order() + +def lib_cc_configure_tests(name): + """Creates the test suite for lib_cc_configure.bzl tests. + + Args: + name: The name of the test suite. + """ + test_suite( + name = name, + basic_tests = [ + _test_split_escaped, + ], + )