@@ -40,29 +40,29 @@ pub(super) fn check_file_headers(file_path: &Path) -> Result<(), HeaderError> {
40
40
DirectiveMatchResult :: UseUiTestComment => {
41
41
errors. push ( HeaderAction {
42
42
line_num,
43
- line : comment. full_line ( ) . to_string ( ) ,
43
+ line : comment. full_line ( ) . to_owned ( ) ,
44
44
action : LineAction :: UseUiTestComment ,
45
45
} ) ;
46
46
break ;
47
47
}
48
48
DirectiveMatchResult :: MigrateToUiTest => {
49
49
errors. push ( HeaderAction {
50
50
line_num,
51
- line : comment. full_line ( ) . to_string ( ) ,
51
+ line : comment. full_line ( ) . to_owned ( ) ,
52
52
action : LineAction :: MigrateToUiTest {
53
- compiletest_name : directive. compiletest_name ( ) . to_string ( ) ,
54
- ui_test_name : directive. ui_test_name ( ) . unwrap ( ) . to_string ( ) ,
53
+ compiletest_name : directive. compiletest_name ( ) . to_owned ( ) ,
54
+ ui_test_name : directive. ui_test_name ( ) . unwrap ( ) . to_owned ( ) ,
55
55
} ,
56
56
} ) ;
57
57
break ;
58
58
}
59
59
DirectiveMatchResult :: UseUITestName => {
60
60
errors. push ( HeaderAction {
61
61
line_num,
62
- line : comment. full_line ( ) . to_string ( ) ,
62
+ line : comment. full_line ( ) . to_owned ( ) ,
63
63
action : LineAction :: UseUITestName {
64
- compiletest_name : directive. compiletest_name ( ) . to_string ( ) ,
65
- ui_test_name : directive. ui_test_name ( ) . unwrap ( ) . to_string ( ) ,
64
+ compiletest_name : directive. compiletest_name ( ) . to_owned ( ) ,
65
+ ui_test_name : directive. ui_test_name ( ) . unwrap ( ) . to_owned ( ) ,
66
66
} ,
67
67
} ) ;
68
68
break ;
@@ -75,24 +75,29 @@ pub(super) fn check_file_headers(file_path: &Path) -> Result<(), HeaderError> {
75
75
Err ( ConditionError :: ConvertToUiTest { compiletest_name, ui_test_name } ) => {
76
76
errors. push ( HeaderAction {
77
77
line_num,
78
- line : comment. full_line ( ) . to_string ( ) ,
78
+ line : comment. full_line ( ) . to_owned ( ) ,
79
79
action : LineAction :: MigrateToUiTest { compiletest_name, ui_test_name } ,
80
80
} )
81
81
}
82
82
Err ( ConditionError :: UiTestUnknownTarget { target_substr } ) => {
83
83
errors. push ( HeaderAction {
84
84
line_num,
85
- line : comment. full_line ( ) . to_string ( ) ,
85
+ line : comment. full_line ( ) . to_owned ( ) ,
86
86
action : LineAction :: Error {
87
87
message : format ! ( "invalid target substring: {}" , target_substr) ,
88
88
} ,
89
89
} )
90
90
}
91
91
Err ( ConditionError :: UseUiTestComment ) => errors. push ( HeaderAction {
92
92
line_num,
93
- line : comment. full_line ( ) . to_string ( ) ,
93
+ line : comment. full_line ( ) . to_owned ( ) ,
94
94
action : LineAction :: UseUiTestComment ,
95
95
} ) ,
96
+ Err ( ConditionError :: UnknownCondition { name } ) => errors. push ( HeaderAction {
97
+ line_num,
98
+ line : comment. full_line ( ) . to_owned ( ) ,
99
+ action : LineAction :: Error { message : format ! ( "unknown condition {}" , name) } ,
100
+ } ) ,
96
101
}
97
102
} ) ;
98
103
@@ -182,6 +187,8 @@ enum ConditionError {
182
187
ConvertToUiTest { compiletest_name : String , ui_test_name : String } ,
183
188
/// The target substring in the comment is not known.
184
189
UiTestUnknownTarget { target_substr : String } ,
190
+ /// The comment looked like a condition, but was not known.
191
+ UnknownCondition { name : String } ,
185
192
}
186
193
187
194
/// Checks that a test comment uses the ui_test style only or ignore directives, and that
@@ -213,19 +220,16 @@ fn check_condition(comment: &TestComment<'_>) -> Result<(), ConditionError> {
213
220
// wasm32-bare is an alias for wasm32-unknown-unknown
214
221
Err ( ConditionError :: ConvertToUiTest {
215
222
compiletest_name : String :: from ( "wasm32-bare" ) ,
216
- ui_test_name : String :: from ( "wasm32-unknown-unknown" ) ,
223
+ ui_test_name : String :: from ( "target- wasm32-unknown-unknown" ) ,
217
224
} )
218
- } else if condition. starts_with ( "tidy-" )
219
- || [ "stable" , "beta" , "nightly" , "stage1" , "cross-compile" , "remote" ]
220
- . contains ( & condition)
221
- {
222
- // Ignore tidy directives, and a few other unknown comment types
223
- // FIXME (ui_test): make ui_test know about all of these
225
+ } else if condition. starts_with ( "tidy-" ) {
226
+ // Ignore tidy directives
224
227
Ok ( ( ) )
225
- } else {
226
- // Unknown only/ignore directive, or the target is not known, do nothing.
227
- eprintln ! ( "unknown comment: {:#?}" , comment) ;
228
+ } else if UNSUPPORTED_CONDITIONS . contains ( & condition) {
228
229
Ok ( ( ) )
230
+ } else {
231
+ // Unknown only/ignore directive, or the target is not known.
232
+ Err ( ConditionError :: UnknownCondition { name : condition. to_owned ( ) } )
229
233
}
230
234
}
231
235
@@ -321,6 +325,30 @@ impl From<io::Error> for HeaderError {
321
325
}
322
326
}
323
327
328
+ /// Directives that ui_test does not yet support. Used for emitting a warning instead of an error
329
+ /// in tidy.
330
+ // FIXME (ui_test): This should ideally be empty/removed by supporting everything.
331
+ const UNSUPPORTED_CONDITIONS : & [ & str ] = [
332
+ "stable" ,
333
+ "beta" ,
334
+ "nightly" ,
335
+ "stage1" ,
336
+ "remote" ,
337
+ "cross-compile" ,
338
+ "debug" , // When building with debug assertions enabled. Primarily used for codegen tests.
339
+ // `ignore-pass` is sorta like ui_test's `check-pass` but not really, compiletest instead
340
+ // Falls back to a pass-mode which can be set by headers.
341
+ "pass" ,
342
+ "endian-big" ,
343
+ "compare-mode-polonius" ,
344
+ "compare-mode-next-solver" ,
345
+ "compare-mode-next-solver-coherence" ,
346
+ "compare-mode-split-dwarf" ,
347
+ "compare-mode-split-dwarf-single" ,
348
+ "llvm-version" ,
349
+ ]
350
+ . as_slice ( ) ;
351
+
324
352
// All components of target triples (including the whole triple) that were known by compiletest
325
353
// at the time of writing (2023-08-13). This list is used to guide migration to ui_test style
326
354
// only/ignore directives, since ui_test only knows how to do substring matches on target triples
@@ -556,6 +584,7 @@ const KNOWN_TARGET_COMPONENTS: &[&str] = [
556
584
"tvos" ,
557
585
"uefi" ,
558
586
"unknown" ,
587
+ "uwp" ,
559
588
"vita" ,
560
589
"vxworks" ,
561
590
"wasi" ,
0 commit comments