Skip to content

Commit 01a1ece

Browse files
pzembrodcopybara-github
authored andcommitted
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
1 parent 011d6d9 commit 01a1ece

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

test/cc/common/cc_binary_configured_target_tests.bzl renamed to tests/cc/common/cc_binary_configured_target_tests.bzl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
44
load("@rules_testing//lib:util.bzl", "util")
55
load("//cc:cc_binary.bzl", "cc_binary")
66

7-
def _test_files_to_build(name):
7+
def _test_files_to_build(name, binary_extension):
88
util.helper_target(
99
cc_binary,
1010
name = name + "/hello",
@@ -13,17 +13,34 @@ def _test_files_to_build(name):
1313
analysis_test(
1414
name = name,
1515
impl = _test_files_to_build_impl,
16+
attrs = {
17+
"binary_extension": attr.string(),
18+
},
19+
attr_values = {
20+
"binary_extension": binary_extension,
21+
},
1622
target = name + "/hello",
1723
)
1824

1925
def _test_files_to_build_impl(env, target):
20-
env.expect.that_target(target).default_outputs().contains_exactly(["{package}/{name}"])
21-
env.expect.that_target(target).executable().short_path_equals("{package}/{name}")
26+
expected_extension = env.ctx.attr.binary_extension
27+
expected_name = "{package}/{name}".format(
28+
package = target.label.package,
29+
name = target.label.name,
30+
) + expected_extension
31+
env.expect.that_target(target).default_outputs().contains_exactly([expected_name])
32+
env.expect.that_target(target).executable().short_path_equals(expected_name)
2233

2334
def cc_binary_configured_target_tests(name):
2435
test_suite(
2536
name = name,
2637
tests = [
2738
_test_files_to_build,
2839
],
40+
test_kwargs = {
41+
"binary_extension": select({
42+
"@platforms//os:windows": ".exe",
43+
"//conditions:default": "",
44+
}),
45+
},
2946
)

0 commit comments

Comments
 (0)