fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
184da7d4
patching
1"""Analysis test for for rust_bindgen_library rule.""" 2 3load ( "@rules_cc//cc:defs.bzl" , "cc_library" ) 4load ( "@rules_rust//bindgen:defs.bzl" , "rust_bindgen_library" ) 5load ( "@rules_rust//rust:defs.bzl" , "rust_binary" ) 6load ( "@rules_testing//lib:analysis_test.bzl" , "analysis_test" , "test_suite" ) 7 8def _test_cc_linkopt_impl ( env , target ): 9# Assert 10env . expect . that_action ( target . actions [ 0 ]) \ 11. contains_at_least_args ([ "--codegen=link-arg=-shared" ]) 12 13def _test_cc_linkopt ( name ): 14# Arrange 15cc_library ( 16name = name + "_cc" , 17srcs = [ "simple.cc" ], 18hdrs = [ "simple.h" ], 19linkopts = [ "-shared" ], 20tags = [ "manual" ], 21) 22rust_bindgen_library ( 23name = name + "_rust_bindgen" , 24cc_lib = name + "_cc" , 25header = "simple.h" , 26tags = [ "manual" ], 27edition = "2021" , 28) 29rust_binary ( 30name = name + "_rust_binary" , 31srcs = [ "main.rs" ], 32deps = [ name + "_rust_bindgen" ], 33tags = [ "manual" ], 34edition = "2021" , 35) 36 37# Act 38# TODO: Use targets attr to also verify `rust_bindgen_library` not having 39# the linkopt after https://github.com/bazelbuild/rules_testing/issues/67 40# is released 41analysis_test ( 42name = name , 43target = name + "_rust_binary" , 44impl = _test_cc_linkopt_impl , 45) 46 47def bindgen_test_suite ( name ): 48test_suite ( 49name = name , 50tests = [ 51_test_cc_linkopt , 52], 53)