@@ -4,7 +4,7 @@ load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
44load ("@rules_testing//lib:util.bzl" , "util" )
55load ("//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
1925def _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
2334def 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