Move the new rules_cc/test/cc to rules_cc/tests/cc where the previous tests already live. Oversight during the initial CL. PiperOrigin-RevId: 877344848 Change-Id: I9c843ee6594dd9cd72044a0c88464db637e0e424
diff --git a/test/cc/common/cc_binary_configured_target_tests.bzl b/test/cc/common/cc_binary_configured_target_tests.bzl deleted file mode 100644 index 48008b5..0000000 --- a/test/cc/common/cc_binary_configured_target_tests.bzl +++ /dev/null
@@ -1,29 +0,0 @@ -"""Tests for cc_binary.""" - -load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite") -load("@rules_testing//lib:util.bzl", "util") -load("//cc:cc_binary.bzl", "cc_binary") - -def _test_files_to_build(name): - util.helper_target( - cc_binary, - name = name + "/hello", - srcs = ["hello.cc"], - ) - analysis_test( - name = name, - impl = _test_files_to_build_impl, - target = name + "/hello", - ) - -def _test_files_to_build_impl(env, target): - env.expect.that_target(target).default_outputs().contains_exactly(["{package}/{name}"]) - env.expect.that_target(target).executable().short_path_equals("{package}/{name}") - -def cc_binary_configured_target_tests(name): - test_suite( - name = name, - tests = [ - _test_files_to_build, - ], - )
diff --git a/test/cc/common/BUILD b/tests/cc/common/BUILD similarity index 100% rename from test/cc/common/BUILD rename to tests/cc/common/BUILD
diff --git a/tests/cc/common/cc_binary_configured_target_tests.bzl b/tests/cc/common/cc_binary_configured_target_tests.bzl new file mode 100644 index 0000000..1393325 --- /dev/null +++ b/tests/cc/common/cc_binary_configured_target_tests.bzl
@@ -0,0 +1,46 @@ +"""Tests for cc_binary.""" + +load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite") +load("@rules_testing//lib:util.bzl", "util") +load("//cc:cc_binary.bzl", "cc_binary") + +def _test_files_to_build(name, binary_extension): + util.helper_target( + cc_binary, + name = name + "/hello", + srcs = ["hello.cc"], + ) + analysis_test( + name = name, + impl = _test_files_to_build_impl, + attrs = { + "binary_extension": attr.string(), + }, + attr_values = { + "binary_extension": binary_extension, + }, + target = name + "/hello", + ) + +def _test_files_to_build_impl(env, target): + expected_extension = env.ctx.attr.binary_extension + expected_name = "{package}/{name}".format( + package = target.label.package, + name = target.label.name, + ) + expected_extension + env.expect.that_target(target).default_outputs().contains_exactly([expected_name]) + env.expect.that_target(target).executable().short_path_equals(expected_name) + +def cc_binary_configured_target_tests(name): + test_suite( + name = name, + tests = [ + _test_files_to_build, + ], + test_kwargs = { + "binary_extension": select({ + "@platforms//os:windows": ".exe", + "//conditions:default": "", + }), + }, + )