File tree 6 files changed +78
-0
lines changed
6 files changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -76,3 +76,10 @@ http_archive(
76
76
#
77
77
# load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
78
78
# rbe_preconfig(name = "buildkite_config", toolchain = "ubuntu2004-bazel-java11")
79
+
80
+ http_archive (
81
+ name = "rules_testing" ,
82
+ sha256 = "b84ed8546f1969d700ead4546de9f7637e0f058d835e47e865dcbb13c4210aed" ,
83
+ strip_prefix = "rules_testing-0.5.0" ,
84
+ url = "https://github.com/bazelbuild/rules_testing/releases/download/v0.5.0/rules_testing-v0.5.0.tar.gz" ,
85
+ )
Original file line number Diff line number Diff line change
1
+ load (":bindgen_test.bzl" , "bindgen_test_suite" )
2
+
3
+ bindgen_test_suite (name = "cc_bindgen_test_suite" )
Original file line number Diff line number Diff line change
1
+ """Analysis test for for rust_bindgen_library rule."""
2
+
3
+ load ("@rules_cc//cc:defs.bzl" , "cc_library" )
4
+ load ("@rules_rust//bindgen:defs.bzl" , "rust_bindgen_library" )
5
+ load ("@rules_rust//rust:defs.bzl" , "rust_binary" )
6
+ load ("@rules_testing//lib:analysis_test.bzl" , "analysis_test" , "test_suite" )
7
+
8
+ def _test_cc_linkopt_impl (env , target ):
9
+ # Assert
10
+ env .expect .that_action (target .actions [0 ]) \
11
+ .contains_at_least_args (["--codegen=link-arg=-shared" ])
12
+
13
+ def _test_cc_linkopt (name ):
14
+ # Arrange
15
+ cc_library (
16
+ name = name + "_cc" ,
17
+ srcs = ["simple.cc" ],
18
+ hdrs = ["simple.h" ],
19
+ linkopts = ["-shared" ],
20
+ tags = ["manual" ],
21
+ )
22
+ rust_bindgen_library (
23
+ name = name + "_rust_bindgen" ,
24
+ cc_lib = name + "_cc" ,
25
+ header = "simple.h" ,
26
+ tags = ["manual" ],
27
+ edition = "2021" ,
28
+ )
29
+ rust_binary (
30
+ name = name + "_rust_binary" ,
31
+ srcs = ["main.rs" ],
32
+ deps = [name + "_rust_bindgen" ],
33
+ tags = ["manual" ],
34
+ edition = "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
41
+ analysis_test (
42
+ name = name ,
43
+ target = name + "_rust_binary" ,
44
+ impl = _test_cc_linkopt_impl ,
45
+ )
46
+
47
+ def bindgen_test_suite (name ):
48
+ test_suite (
49
+ name = name ,
50
+ tests = [
51
+ _test_cc_linkopt ,
52
+ ],
53
+ )
Original file line number Diff line number Diff line change
1
+ // Analysis test shouldn't need this file.
2
+ // This is a workaround until
3
+ // https://github.com/bazelbuild/rules_rust/issues/2499
4
+ // is fixed
5
+ fn main ( ) {
6
+ println ! ( "Hello world" ) ;
7
+ }
Original file line number Diff line number Diff line change
1
+ // Analysis test shouldn't need this file.
2
+ // This is a workaround until
3
+ // https://github.com/bazelbuild/rules_rust/issues/2499
4
+ // is fixed
Original file line number Diff line number Diff line change
1
+ // Analysis test shouldn't need this file.
2
+ // This is a workaround until
3
+ // https://github.com/bazelbuild/rules_rust/issues/2499
4
+ // is fixed
You can’t perform that action at this time.
0 commit comments