Creates _test_files_to_build for cc_binary() in new rules_cc/test/cc/common/cc_binary_configured_target_test.bzl PiperOrigin-RevId: 876198815 Change-Id: I3c67dc7dc3c27f0c87c9e76776b053eace3891b5
diff --git a/test/cc/common/BUILD b/test/cc/common/BUILD new file mode 100644 index 0000000..91acc88 --- /dev/null +++ b/test/cc/common/BUILD
@@ -0,0 +1,3 @@ +load(":cc_binary_configured_target_tests.bzl", "cc_binary_configured_target_tests") + +cc_binary_configured_target_tests(name = "cc_binary_configured_target_tests")
diff --git a/test/cc/common/cc_binary_configured_target_tests.bzl b/test/cc/common/cc_binary_configured_target_tests.bzl new file mode 100644 index 0000000..48008b5 --- /dev/null +++ b/test/cc/common/cc_binary_configured_target_tests.bzl
@@ -0,0 +1,29 @@ +"""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, + ], + )