File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -370,7 +370,7 @@ def _filter_inputs(
370370 cc_toolchain ,
371371 linker_input ,
372372 )
373- elif _check_if_target_should_be_exported_with_filter (
373+ if _check_if_target_should_be_exported_with_filter (
374374 linker_input .owner ,
375375 ctx .label ,
376376 ctx .attr .exports_filter ,
Original file line number Diff line number Diff line change 1010 "forwarding_cc_lib",
1111 "nocode_cc_lib",
1212 "wrapped_cc_lib",
13+ "exports_test",
1314)
1415load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
1516
@@ -117,6 +118,9 @@ cc_shared_library(
117118 "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library3:diff_pkg_so"
118119 ],
119120 features = ["windows_export_all_symbols"],
121+ exports_filter = [
122+ ":indirect_dep2",
123+ ],
120124 deps = [
121125 "baz",
122126 "foo",
@@ -472,3 +476,17 @@ build_failure_test(
472476 message = "Do not place libraries which only contain a precompiled dynamic library",
473477 target = "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/failing_targets:failing_only_dynamic_lib",
474478)
479+
480+ exports_test(
481+ name = "exports_foo_test",
482+ target = ":foo_so",
483+ targets_that_should_be_claimed_to_be_exported = [
484+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:indirect_dep2",
485+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:baz",
486+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:foo",
487+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:cc_lib_with_no_srcs",
488+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:nocode_cc_lib",
489+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:should_not_be_linked_cc_lib",
490+ "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:a_suffix",
491+ ],
492+ )
Original file line number Diff line number Diff line change @@ -331,3 +331,27 @@ nocode_cc_lib = rule(
331331 },
332332 provides = [CcInfo ],
333333)
334+
335+ def _exports_test_impl (env , target ):
336+ actual = list (target [CcSharedLibraryInfo ].exports )
337+
338+ # Remove the @ prefix on Bazel
339+ for i in range (len (actual )):
340+ if actual [i ][0 ] == "@" :
341+ actual [i ] = actual [i ][1 :]
342+ expected = env .ctx .attr ._targets_that_should_be_claimed_to_be_exported
343+ env .expect .where (
344+ detail = "Exports lists do not match." ,
345+ ).that_collection (actual ).contains_exactly (expected ).in_order ()
346+
347+ def _exports_test_macro (name , target , targets_that_should_be_claimed_to_be_exported ):
348+ analysis_test (
349+ name = name ,
350+ impl = _exports_test_impl ,
351+ target = target ,
352+ attrs = {
353+ "_targets_that_should_be_claimed_to_be_exported" : attr .string_list (default = targets_that_should_be_claimed_to_be_exported ),
354+ },
355+ )
356+
357+ exports_test = _exports_test_macro
You can’t perform that action at this time.
0 commit comments