1
+ use test_common:: { CommentKind , TestComment } ;
2
+
1
3
use crate :: common:: { Config , Debugger } ;
2
4
use crate :: header:: IgnoreDecision ;
3
5
use crate :: util;
4
6
5
7
pub ( super ) fn handle_needs (
6
8
cache : & CachedNeedsConditions ,
7
9
config : & Config ,
8
- ln : & str ,
10
+ comment : TestComment < ' _ > ,
9
11
) -> IgnoreDecision {
10
12
// Note that we intentionally still put the needs- prefix here to make the file show up when
11
13
// grepping for a directive name, even though we could technically strip that.
12
14
let needs = & [
13
15
Need {
14
- names : & [ "needs-asm-support" , "@needs-asm-support" ] ,
16
+ compiletest_name : "needs-asm-support" ,
17
+ ui_test_name : Some ( "needs-asm-support" ) ,
15
18
condition : config. has_asm_support ( ) ,
16
19
ignore_reason : "ignored on targets without inline assembly support" ,
17
20
} ,
18
21
Need {
19
- names : & [ "needs-sanitizer-support" ] ,
22
+ compiletest_name : "needs-sanitizer-support" ,
23
+ ui_test_name : None ,
20
24
condition : cache. sanitizer_support ,
21
25
ignore_reason : "ignored on targets without sanitizers support" ,
22
26
} ,
23
27
Need {
24
- names : & [ "needs-sanitizer-address" ] ,
28
+ compiletest_name : "needs-sanitizer-address" ,
29
+ ui_test_name : None ,
25
30
condition : cache. sanitizer_address ,
26
31
ignore_reason : "ignored on targets without address sanitizer" ,
27
32
} ,
28
33
Need {
29
- names : & [ "needs-sanitizer-cfi" ] ,
34
+ compiletest_name : "needs-sanitizer-cfi" ,
35
+ ui_test_name : None ,
30
36
condition : cache. sanitizer_cfi ,
31
37
ignore_reason : "ignored on targets without CFI sanitizer" ,
32
38
} ,
33
39
Need {
34
- names : & [ "needs-sanitizer-kcfi" ] ,
40
+ compiletest_name : "needs-sanitizer-kcfi" ,
41
+ ui_test_name : None ,
35
42
condition : cache. sanitizer_kcfi ,
36
43
ignore_reason : "ignored on targets without kernel CFI sanitizer" ,
37
44
} ,
38
45
Need {
39
- names : & [ "needs-sanitizer-kasan" ] ,
46
+ compiletest_name : "needs-sanitizer-kasan" ,
47
+ ui_test_name : None ,
40
48
condition : cache. sanitizer_kasan ,
41
49
ignore_reason : "ignored on targets without kernel address sanitizer" ,
42
50
} ,
43
51
Need {
44
- names : & [ "needs-sanitizer-leak" ] ,
52
+ compiletest_name : "needs-sanitizer-leak" ,
53
+ ui_test_name : None ,
45
54
condition : cache. sanitizer_leak ,
46
55
ignore_reason : "ignored on targets without leak sanitizer" ,
47
56
} ,
48
57
Need {
49
- names : & [ "needs-sanitizer-memory" ] ,
58
+ compiletest_name : "needs-sanitizer-memory" ,
59
+ ui_test_name : None ,
50
60
condition : cache. sanitizer_memory ,
51
61
ignore_reason : "ignored on targets without memory sanitizer" ,
52
62
} ,
53
63
Need {
54
- names : & [ "needs-sanitizer-thread" ] ,
64
+ compiletest_name : "needs-sanitizer-thread" ,
65
+ ui_test_name : None ,
55
66
condition : cache. sanitizer_thread ,
56
67
ignore_reason : "ignored on targets without thread sanitizer" ,
57
68
} ,
58
69
Need {
59
- names : & [ "needs-sanitizer-hwaddress" ] ,
70
+ compiletest_name : "needs-sanitizer-hwaddress" ,
71
+ ui_test_name : None ,
60
72
condition : cache. sanitizer_hwaddress ,
61
73
ignore_reason : "ignored on targets without hardware-assisted address sanitizer" ,
62
74
} ,
63
75
Need {
64
- names : & [ "needs-sanitizer-memtag" ] ,
76
+ compiletest_name : "needs-sanitizer-memtag" ,
77
+ ui_test_name : None ,
65
78
condition : cache. sanitizer_memtag ,
66
79
ignore_reason : "ignored on targets without memory tagging sanitizer" ,
67
80
} ,
68
81
Need {
69
- names : & [ "needs-sanitizer-shadow-call-stack" ] ,
82
+ compiletest_name : "needs-sanitizer-shadow-call-stack" ,
83
+ ui_test_name : None ,
70
84
condition : cache. sanitizer_shadow_call_stack ,
71
85
ignore_reason : "ignored on targets without shadow call stacks" ,
72
86
} ,
73
87
Need {
74
- names : & [ "needs-sanitizer-safestack" ] ,
88
+ compiletest_name : "needs-sanitizer-safestack" ,
89
+ ui_test_name : None ,
75
90
condition : cache. sanitizer_safestack ,
76
91
ignore_reason : "ignored on targets without SafeStack support" ,
77
92
} ,
78
93
Need {
79
- names : & [ "needs-run-enabled" ] ,
94
+ compiletest_name : "needs-run-enabled" ,
95
+ ui_test_name : None ,
80
96
condition : config. run_enabled ( ) ,
81
97
ignore_reason : "ignored when running the resulting test binaries is disabled" ,
82
98
} ,
83
99
Need {
84
- names : & [ "needs-unwind" ] ,
100
+ compiletest_name : "needs-unwind" ,
101
+ ui_test_name : None ,
85
102
condition : config. can_unwind ( ) ,
86
103
ignore_reason : "ignored on targets without unwinding support" ,
87
104
} ,
88
105
Need {
89
- names : & [ "needs-profiler-support" ] ,
106
+ compiletest_name : "needs-profiler-support" ,
107
+ ui_test_name : None ,
90
108
condition : cache. profiler_support ,
91
109
ignore_reason : "ignored when profiler support is disabled" ,
92
110
} ,
93
111
Need {
94
- names : & [ "needs-matching-clang" ] ,
112
+ compiletest_name : "needs-matching-clang" ,
113
+ ui_test_name : None ,
95
114
condition : config. run_clang_based_tests_with . is_some ( ) ,
96
115
ignore_reason : "ignored when the used clang does not match the built LLVM" ,
97
116
} ,
98
117
Need {
99
- names : & [ "needs-xray" ] ,
118
+ compiletest_name : "needs-xray" ,
119
+ ui_test_name : None ,
100
120
condition : cache. xray ,
101
121
ignore_reason : "ignored on targets without xray tracing" ,
102
122
} ,
103
123
Need {
104
- names : & [ "needs-rust-lld" ] ,
124
+ compiletest_name : "needs-rust-lld" ,
125
+ ui_test_name : None ,
105
126
condition : cache. rust_lld ,
106
127
ignore_reason : "ignored on targets without Rust's LLD" ,
107
128
} ,
108
129
Need {
109
- names : & [ "needs-rust-lldb" ] ,
130
+ compiletest_name : "needs-rust-lldb" ,
131
+ ui_test_name : None ,
110
132
condition : config. debugger != Some ( Debugger :: Lldb ) || config. lldb_native_rust ,
111
133
ignore_reason : "ignored on targets without Rust's LLDB" ,
112
134
} ,
113
135
Need {
114
- names : & [ "needs-i686-dlltool" ] ,
136
+ compiletest_name : "needs-i686-dlltool" ,
137
+ ui_test_name : None ,
115
138
condition : cache. i686_dlltool ,
116
139
ignore_reason : "ignored when dlltool for i686 is not present" ,
117
140
} ,
118
141
Need {
119
- names : & [ "needs-x86_64-dlltool" ] ,
142
+ compiletest_name : "needs-x86_64-dlltool" ,
143
+ ui_test_name : None ,
120
144
condition : cache. x86_64_dlltool ,
121
145
ignore_reason : "ignored when dlltool for x86_64 is not present" ,
122
146
} ,
123
147
Need {
124
- names : & [ "needs-dlltool" ] ,
148
+ compiletest_name : "needs-dlltool" ,
149
+ ui_test_name : None ,
125
150
condition : cache. dlltool ,
126
151
ignore_reason : "ignored when dlltool for the current architecture is not present" ,
127
152
} ,
128
153
Need {
129
- names : & [ "needs-git-hash" ] ,
154
+ compiletest_name : "needs-git-hash" ,
155
+ ui_test_name : None ,
130
156
condition : config. git_hash ,
131
157
ignore_reason : "ignored when git hashes have been omitted for building" ,
132
158
} ,
133
159
Need {
134
- names : & [ "needs-dynamic-linking" ] ,
160
+ compiletest_name : "needs-dynamic-linking" ,
161
+ ui_test_name : None ,
135
162
condition : config. target_cfg ( ) . dynamic_linking ,
136
163
ignore_reason : "ignored on targets without dynamic linking" ,
137
164
} ,
138
165
] ;
139
166
140
- let ( name, comment) = match ln. split_once ( [ ':' , ' ' ] ) {
141
- Some ( ( name, comment) ) => ( name, Some ( comment) ) ,
167
+ let ln = comment. comment_str ( ) ;
168
+ let ( name, args) = match ln. split_once ( [ ':' , ' ' ] ) {
169
+ Some ( ( name, args) ) => ( name, Some ( args) ) ,
142
170
None => ( ln, None ) ,
143
171
} ;
144
172
@@ -153,13 +181,13 @@ pub(super) fn handle_needs(
153
181
154
182
let mut found_valid = false ;
155
183
for need in needs {
156
- if need. names . contains ( & name ) {
184
+ if need. matches_comment ( comment ) {
157
185
if need. condition {
158
186
found_valid = true ;
159
187
break ;
160
188
} else {
161
189
return IgnoreDecision :: Ignore {
162
- reason : if let Some ( comment) = comment {
190
+ reason : if let Some ( comment) = args {
163
191
format ! ( "{} ({comment})" , need. ignore_reason)
164
192
} else {
165
193
need. ignore_reason . into ( )
@@ -176,12 +204,25 @@ pub(super) fn handle_needs(
176
204
}
177
205
}
178
206
207
+ #[ derive( Debug , Clone , Copy ) ]
179
208
struct Need {
180
- names : & ' static [ & ' static str ] ,
209
+ compiletest_name : & ' static str ,
210
+ ui_test_name : Option < & ' static str > ,
181
211
condition : bool ,
182
212
ignore_reason : & ' static str ,
183
213
}
184
214
215
+ impl Need {
216
+ fn matches_comment ( & self , comment : TestComment < ' _ > ) -> bool {
217
+ match comment. comment ( ) {
218
+ CommentKind :: Compiletest ( line) => line. starts_with ( self . compiletest_name ) ,
219
+ CommentKind :: UiTest ( line) => {
220
+ self . ui_test_name . is_some_and ( |ui_test_name| line. starts_with ( ui_test_name) )
221
+ }
222
+ }
223
+ }
224
+ }
225
+
185
226
pub ( super ) struct CachedNeedsConditions {
186
227
sanitizer_support : bool ,
187
228
sanitizer_address : bool ,
0 commit comments