@@ -40,29 +40,29 @@ pub(super) fn check_file_headers(file_path: &Path) -> Result<(), HeaderError> {
4040 DirectiveMatchResult :: UseUiTestComment => {
4141 errors. push ( HeaderAction {
4242 line_num,
43- line : comment. full_line ( ) . to_string ( ) ,
43+ line : comment. full_line ( ) . to_owned ( ) ,
4444 action : LineAction :: UseUiTestComment ,
4545 } ) ;
4646 break ;
4747 }
4848 DirectiveMatchResult :: MigrateToUiTest => {
4949 errors. push ( HeaderAction {
5050 line_num,
51- line : comment. full_line ( ) . to_string ( ) ,
51+ line : comment. full_line ( ) . to_owned ( ) ,
5252 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 ( ) ,
5555 } ,
5656 } ) ;
5757 break ;
5858 }
5959 DirectiveMatchResult :: UseUITestName => {
6060 errors. push ( HeaderAction {
6161 line_num,
62- line : comment. full_line ( ) . to_string ( ) ,
62+ line : comment. full_line ( ) . to_owned ( ) ,
6363 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 ( ) ,
6666 } ,
6767 } ) ;
6868 break ;
@@ -75,24 +75,29 @@ pub(super) fn check_file_headers(file_path: &Path) -> Result<(), HeaderError> {
7575 Err ( ConditionError :: ConvertToUiTest { compiletest_name, ui_test_name } ) => {
7676 errors. push ( HeaderAction {
7777 line_num,
78- line : comment. full_line ( ) . to_string ( ) ,
78+ line : comment. full_line ( ) . to_owned ( ) ,
7979 action : LineAction :: MigrateToUiTest { compiletest_name, ui_test_name } ,
8080 } )
8181 }
8282 Err ( ConditionError :: UiTestUnknownTarget { target_substr } ) => {
8383 errors. push ( HeaderAction {
8484 line_num,
85- line : comment. full_line ( ) . to_string ( ) ,
85+ line : comment. full_line ( ) . to_owned ( ) ,
8686 action : LineAction :: Error {
8787 message : format ! ( "invalid target substring: {}" , target_substr) ,
8888 } ,
8989 } )
9090 }
9191 Err ( ConditionError :: UseUiTestComment ) => errors. push ( HeaderAction {
9292 line_num,
93- line : comment. full_line ( ) . to_string ( ) ,
93+ line : comment. full_line ( ) . to_owned ( ) ,
9494 action : LineAction :: UseUiTestComment ,
9595 } ) ,
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+ } ) ,
96101 }
97102 } ) ;
98103
@@ -182,6 +187,8 @@ enum ConditionError {
182187 ConvertToUiTest { compiletest_name : String , ui_test_name : String } ,
183188 /// The target substring in the comment is not known.
184189 UiTestUnknownTarget { target_substr : String } ,
190+ /// The comment looked like a condition, but was not known.
191+ UnknownCondition { name : String } ,
185192}
186193
187194/// 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> {
213220 // wasm32-bare is an alias for wasm32-unknown-unknown
214221 Err ( ConditionError :: ConvertToUiTest {
215222 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" ) ,
217224 } )
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
224227 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) {
228229 Ok ( ( ) )
230+ } else {
231+ // Unknown only/ignore directive, or the target is not known.
232+ Err ( ConditionError :: UnknownCondition { name : condition. to_owned ( ) } )
229233 }
230234 }
231235
@@ -321,6 +325,30 @@ impl From<io::Error> for HeaderError {
321325 }
322326}
323327
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+
324352// All components of target triples (including the whole triple) that were known by compiletest
325353// at the time of writing (2023-08-13). This list is used to guide migration to ui_test style
326354// 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] = [
556584 "tvos" ,
557585 "uefi" ,
558586 "unknown" ,
587+ "uwp" ,
559588 "vita" ,
560589 "vxworks" ,
561590 "wasi" ,
0 commit comments