fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
03a70796
0.8.0
1"""Unittests for rust rules.""" 2 3load ( "@bazel_skylib//lib:unittest.bzl" , "analysistest" , "asserts" ) 4load ( "//rust:defs.bzl" , "rust_common" , "rust_library" ) 5 6def _crate_variants_test_impl ( ctx ): 7env = analysistest . begin ( ctx ) 8tut = analysistest . target_under_test ( env ) 9transitive_crate_outputs = tut [ rust_common . dep_info ]. transitive_crate_outputs . to_list () 10 11# Both variants of "foo" occur as dependencies. 12asserts . equals ( env , len ( transitive_crate_outputs ), 2 ) 13return analysistest . end ( env ) 14 15crate_variants_test = analysistest . make ( _crate_variants_test_impl ) 16 17def _crate_variants_test (): 18rust_library ( 19name = "foo" , 20srcs = [ "foo.rs" ], 21edition = "2018" , 22) 23 24rust_library ( 25name = "foo2" , 26crate_name = "foo" , 27srcs = [ "foo.rs" ], 28edition = "2018" , 29) 30 31rust_library ( 32name = "bar" , 33srcs = [ "bar.rs" ], 34edition = "2018" , 35deps = [ ":foo" , ":foo2" ], 36) 37 38crate_variants_test ( 39name = "crate_variants_test" , 40target_under_test = ":bar" , 41) 42 43def crate_variants_test_suite ( name ): 44"""Entry-point macro called from the BUILD file. 45 46Args: 47name: Name of the macro. 48""" 49_crate_variants_test () 50 51native . test_suite ( 52name = name , 53tests = [ 54":crate_variants_test" , 55], 56)