3
3
load ("@bazel_skylib//lib:unittest.bzl" , "analysistest" , "asserts" )
4
4
load ("//rust:defs.bzl" , "rust_binary" , "rust_shared_library" , "rust_test" )
5
5
6
- def _pdb_file_test_impl (ctx ):
6
+ def _pdb_file_test_impl (ctx , expect_pdb_file ):
7
7
env = analysistest .begin (ctx )
8
8
target = analysistest .target_under_test (env )
9
-
10
9
files = target [DefaultInfo ].files .to_list ()
10
+
11
+ if not expect_pdb_file :
12
+ asserts .equals (env , len (files ), 0 )
13
+ return analysistest .end (env )
14
+
11
15
asserts .equals (env , len (files ), 1 )
12
16
file = files [0 ]
13
17
asserts .equals (env , file .extension , "pdb" )
14
-
15
18
return analysistest .end (env )
16
19
17
- pdb_file_test = analysistest .make (_pdb_file_test_impl )
20
+
21
+
22
+ def _pdb_file_for_dbg_test_impl (ctx ):
23
+ """Test for dbg compilation mode."""
24
+ return _pdb_file_test_impl (ctx , True )
25
+
26
+ pdb_file_dbg_test = analysistest .make (
27
+ _pdb_file_for_dbg_test_impl ,
28
+ config_settings = {
29
+ "//command_line_option:compilation_mode" : "dbg" ,
30
+ }
31
+ )
32
+
33
+ def _pdb_file_for_fastbuild_test_impl (ctx ):
34
+ """Test for fastbuild compilation mode."""
35
+ return _pdb_file_test_impl (ctx , True )
36
+
37
+ pdb_file_fastbuild_test = analysistest .make (
38
+ _pdb_file_for_fastbuild_test_impl ,
39
+ config_settings = {
40
+ "//command_line_option:compilation_mode" : "fastbuild" ,
41
+ }
42
+ )
43
+
44
+ def _pdb_file_for_opt_test_impl (ctx ):
45
+ """Test for opt compilation mode."""
46
+ return _pdb_file_test_impl (ctx , False )
47
+
48
+ pdb_file_opt_test = analysistest .make (
49
+ _pdb_file_for_opt_test_impl ,
50
+ config_settings = {
51
+ "//command_line_option:compilation_mode" : "opt" ,
52
+ }
53
+ )
54
+
55
+ # Mapping from compilation mode to pdb file test.
56
+ pdb_file_tests = {
57
+ "dbg" : pdb_file_dbg_test ,
58
+ "fastbuild" : pdb_file_fastbuild_test ,
59
+ "opt" : pdb_file_opt_test
60
+ }
18
61
19
62
def _dsym_folder_test_impl (ctx ):
20
63
env = analysistest .begin (ctx )
@@ -47,11 +90,12 @@ def debug_info_analysis_test_suite(name):
47
90
output_group = "pdb_file" ,
48
91
)
49
92
50
- pdb_file_test (
51
- name = "lib_pdb_test" ,
52
- target_under_test = ":mylib.pdb" ,
53
- target_compatible_with = ["@platforms//os:windows" ],
54
- )
93
+ for compilation_mode , pdb_test in pdb_file_tests .items ():
94
+ pdb_test (
95
+ name = "lib_pdb_test_{}" .format (compilation_mode ),
96
+ target_under_test = ":mylib.pdb" ,
97
+ target_compatible_with = ["@platforms//os:windows" ],
98
+ )
55
99
56
100
native .filegroup (
57
101
name = "mylib.dSYM" ,
@@ -77,11 +121,12 @@ def debug_info_analysis_test_suite(name):
77
121
output_group = "pdb_file" ,
78
122
)
79
123
80
- pdb_file_test (
81
- name = "bin_pdb_test" ,
82
- target_under_test = ":mybin.pdb" ,
83
- target_compatible_with = ["@platforms//os:windows" ],
84
- )
124
+ for compilation_mode , pdb_test in pdb_file_tests .items ():
125
+ pdb_test (
126
+ name = "bin_pdb_test_{}" .format (compilation_mode ),
127
+ target_under_test = ":mybin.pdb" ,
128
+ target_compatible_with = ["@platforms//os:windows" ],
129
+ )
85
130
86
131
native .filegroup (
87
132
name = "mybin.dSYM" ,
@@ -108,11 +153,12 @@ def debug_info_analysis_test_suite(name):
108
153
testonly = True ,
109
154
)
110
155
111
- pdb_file_test (
112
- name = "test_pdb_test" ,
113
- target_under_test = ":mytest.pdb" ,
114
- target_compatible_with = ["@platforms//os:windows" ],
115
- )
156
+ for compilation_mode , pdb_test in pdb_file_tests .items ():
157
+ pdb_test (
158
+ name = "test_pdb_test_{}" .format (compilation_mode ),
159
+ target_under_test = ":mytest.pdb" ,
160
+ target_compatible_with = ["@platforms//os:windows" ],
161
+ )
116
162
117
163
native .filegroup (
118
164
name = "mytest.dSYM" ,
@@ -130,11 +176,17 @@ def debug_info_analysis_test_suite(name):
130
176
native .test_suite (
131
177
name = name ,
132
178
tests = [
133
- ":lib_pdb_test" ,
134
179
":lib_dsym_test" ,
135
- ":bin_pdb_test" ,
136
180
":bin_dsym_test" ,
137
- ":test_pdb_test" ,
138
181
":test_dsym_test" ,
182
+ ] + [
183
+ ":lib_pdb_test_{}" .format (compilation_mode )
184
+ for compilation_mode in pdb_file_tests
185
+ ] + [
186
+ ":bin_pdb_test_{}" .format (compilation_mode )
187
+ for compilation_mode in pdb_file_tests
188
+ ] + [
189
+ ":test_pdb_test_{}" .format (compilation_mode )
190
+ for compilation_mode in pdb_file_tests
139
191
],
140
192
)
0 commit comments