Commit 6979328 1 parent 65c8f18 commit 6979328 Copy full SHA for 6979328
File tree 7 files changed +154
-0
lines changed
7 files changed +154
-0
lines changed Original file line number Diff line number Diff line change 1
1
# This package aids testing the 'copy_directory' rule.
2
2
3
3
load ("//rules:copy_directory.bzl" , "copy_directory" )
4
+ load ("//tests/copy_directory:mnemonic_test.bzl" , "copy_directory_mnemonic_test" )
4
5
load (":empty_directory.bzl" , "empty_directory" )
5
6
6
7
licenses (["notice" ])
@@ -41,3 +42,16 @@ sh_test(
41
42
],
42
43
deps = ["@bazel_tools//tools/bash/runfiles" ],
43
44
)
45
+
46
+ copy_directory (
47
+ name = "copy_directory_mnemonic_test_target" ,
48
+ src = "dir_with_subdir" ,
49
+ out = "copied_dir_with_subdir" ,
50
+ mnemonic = "FooBar" ,
51
+ tags = ["manual" ],
52
+ )
53
+
54
+ copy_directory_mnemonic_test (
55
+ name = "copy_directory_mnemonic_test" ,
56
+ target_under_test = ":copy_directory_mnemonic_test_target" ,
57
+ )
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 The Bazel Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Custom mnemonic tests for copy_directory.bzl"""
16
+
17
+ load ("//lib:unittest.bzl" , "analysistest" , "asserts" )
18
+
19
+ def _copy_directory_mnemonic_test_impl (ctx ):
20
+ env = analysistest .begin (ctx )
21
+
22
+ expected_mmemonic = "FooBar"
23
+ actual_mnemonic = analysistest .target_actions (env )[0 ].mnemonic
24
+
25
+ asserts .equals (env , expected_mmemonic , actual_mnemonic )
26
+
27
+ return analysistest .end (env )
28
+
29
+ copy_directory_mnemonic_test = analysistest .make (_copy_directory_mnemonic_test_impl )
Original file line number Diff line number Diff line change 32
32
# of it, so we assert that that field contains the output file of the rule
33
33
34
34
load ("//rules:copy_file.bzl" , "copy_file" )
35
+ load ("//tests/copy_file:mnemonic_test.bzl" , "copy_file_mnemonic_test" )
35
36
36
37
licenses (["notice" ])
37
38
@@ -171,3 +172,16 @@ genrule(
171
172
outs = ["b.txt" ],
172
173
cmd = "echo -e '#!/usr/bin/env bash\n echo potato' > $@" ,
173
174
)
175
+
176
+ copy_file (
177
+ name = "copy_file_mnemonic_test_target" ,
178
+ src = "foo.txt" ,
179
+ out = "bar.txt" ,
180
+ mnemonic = "FooBar" ,
181
+ tags = ["manual" ],
182
+ )
183
+
184
+ copy_file_mnemonic_test (
185
+ name = "copy_file_mnemonic_test" ,
186
+ target_under_test = ":copy_file_mnemonic_test_target" ,
187
+ )
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 The Bazel Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Custom mnemonic tests for copy_file.bzl"""
16
+
17
+ load ("//lib:unittest.bzl" , "analysistest" , "asserts" )
18
+
19
+ def _copy_file_mnemonic_test_impl (ctx ):
20
+ env = analysistest .begin (ctx )
21
+
22
+ expected_mmemonic = "FooBar"
23
+ actual_mnemonic = analysistest .target_actions (env )[0 ].mnemonic
24
+
25
+ asserts .equals (env , expected_mmemonic , actual_mnemonic )
26
+
27
+ return analysistest .end (env )
28
+
29
+ copy_file_mnemonic_test = analysistest .make (_copy_file_mnemonic_test_impl )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")
2
2
load ("//rules:diff_test.bzl" , "diff_test" )
3
3
load ("//rules:run_binary.bzl" , "run_binary" )
4
4
load ("//rules:write_file.bzl" , "write_file" )
5
+ load ("//tests/run_binary:mnemonic_test.bzl" , "run_binary_mnemonic_test" )
5
6
6
7
package (
7
8
default_testonly = 1 ,
@@ -165,3 +166,21 @@ cc_binary(
165
166
name = "printargs" ,
166
167
srcs = ["printargs.cc" ],
167
168
)
169
+
170
+ cc_binary (
171
+ name = "hello" ,
172
+ srcs = ["hello.cc" ],
173
+ )
174
+
175
+ run_binary (
176
+ name = "run_binary_test_target" ,
177
+ outs = ["hello.out" ],
178
+ mnemonic = "FooBar" ,
179
+ tags = ["manual" ],
180
+ tool = ":hello" ,
181
+ )
182
+
183
+ run_binary_mnemonic_test (
184
+ name = "run_binary_mnemonic_test" ,
185
+ target_under_test = ":run_binary_test_target" ,
186
+ )
Original file line number Diff line number Diff line change
1
+ // Copyright 2019 The Bazel Authors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include < stdio.h>
16
+
17
+ int main () {
18
+ printf (" Hello, world!" );
19
+ return 0 ;
20
+ }
Original file line number Diff line number Diff line change
1
+ # Copyright 2019 The Bazel Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Custom mnemonic tests for run_binary.bzl"""
16
+
17
+ load ("//lib:unittest.bzl" , "analysistest" , "asserts" )
18
+
19
+ def _run_binary_mnemonic_test_impl (ctx ):
20
+ env = analysistest .begin (ctx )
21
+
22
+ expected_mmemonic = "FooBar"
23
+ actual_mnemonic = analysistest .target_actions (env )[0 ].mnemonic
24
+
25
+ asserts .equals (env , expected_mmemonic , actual_mnemonic )
26
+
27
+ return analysistest .end (env )
28
+
29
+ run_binary_mnemonic_test = analysistest .make (_run_binary_mnemonic_test_impl )
You can’t perform that action at this time.
0 commit comments