@@ -834,28 +834,67 @@ fn valid_ui_error_pattern_test(file: &str) -> bool {
834834 . any ( |to_ignore| file. ends_with ( to_ignore) )
835835}
836836
837- fn contains_ui_error_patterns ( file_path : & Path , _keep_lto_tests : bool ) -> Result < bool , String > {
837+ fn contains_ui_error_patterns ( file_path : & Path , keep_lto_tests : bool ) -> Result < bool , String > {
838838 // Inverted logic: UI tests are expected to fail by default unless marked with pass markers.
839839 // Return false (keep) for tests with pass markers, true (remove) for everything else.
840840 let file = File :: open ( file_path)
841841 . map_err ( |error| format ! ( "Failed to read `{}`: {:?}" , file_path. display( ) , error) ) ?;
842+
843+ let mut has_pass_marker = false ;
842844 for line in BufReader :: new ( file) . lines ( ) . map_while ( Result :: ok) {
843845 let line = line. trim ( ) ;
844846 if line. is_empty ( ) {
845847 continue ;
846848 }
847849
848- // Check for pass markers - these tests should be kept (return false)
850+ if [
851+ "//@ error-pattern:" ,
852+ "//@ build-fail" ,
853+ "//@ run-fail" ,
854+ "//@ known-bug" ,
855+ "-Cllvm-args" ,
856+ "//~" ,
857+ "thread" ,
858+ ]
859+ . iter ( )
860+ . any ( |check| line. contains ( check) )
861+ {
862+ return Ok ( true ) ;
863+ }
864+
865+ if !keep_lto_tests
866+ && ( line. contains ( "-Clto" )
867+ || line. contains ( "-C lto" )
868+ || line. contains ( "compile-flags: -Clinker-plugin-lto" ) )
869+ && !line. contains ( "-Clto=thin" )
870+ {
871+ return Ok ( true ) ;
872+ }
873+
874+ if line. contains ( "//[" ) && line. contains ( "]~" ) {
875+ return Ok ( true ) ;
876+ }
877+ // Check for pass markers
849878 if [ "//@ check-pass" , "//@ build-pass" , "//@ run-pass" ]
850879 . iter ( )
851880 . any ( |marker| line. contains ( marker) )
852881 {
853- return Ok ( false ) ;
882+ has_pass_marker = true ;
854883 }
855884 }
885+ let file_path = file_path. display ( ) . to_string ( ) ;
886+ if file_path. contains ( "ambiguous-4-extern.rs" ) {
887+ eprintln ! ( "nothing found for {file_path:?}" ) ;
888+ }
889+
890+ // The files in this directory contain errors.
891+ if file_path. contains ( "/error-emitter/" ) {
892+ return Ok ( true ) ;
893+ }
856894
857- // Default: remove tests without pass markers (expected to fail by default)
858- Ok ( true )
895+ // If there are no error patterns, check for pass markers
896+ // Keep tests with pass markers, remove tests without them
897+ Ok ( !has_pass_marker)
859898}
860899
861900// # Parameters
0 commit comments