@@ -28,6 +28,7 @@ fn get_runners() -> Runners {
2828 ( "Run failing ui pattern tests" , test_failing_ui_pattern_tests) ,
2929 ) ;
3030 runners. insert ( "--test-failing-rustc" , ( "Run failing rustc tests" , test_failing_rustc) ) ;
31+ runners. insert ( "--run-ui-tests" , ( "Run specified rustc UI tests" , run_ui_tests) ) ;
3132 runners. insert ( "--projects" , ( "Run the tests of popular crates" , test_projects) ) ;
3233 runners. insert ( "--test-libcore" , ( "Run libcore tests" , test_libcore) ) ;
3334 runners. insert ( "--alloc-tests" , ( "Run alloc tests" , test_alloc) ) ;
@@ -1218,6 +1219,45 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String
12181219 )
12191220}
12201221
1222+ fn run_ui_tests ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1223+ let mut env = env. clone ( ) ;
1224+ let rust_path = setup_rustc ( & mut env, args) ?;
1225+
1226+ let extra =
1227+ if args. is_using_gcc_master_branch ( ) { "" } else { " -Csymbol-mangling-version=v0" } ;
1228+
1229+ let rustc_args = format ! (
1230+ "{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot}{extra}" ,
1231+ test_flags = env. get( "TEST_FLAGS" ) . unwrap_or( & String :: new( ) ) ,
1232+ backend = args. config_info. cg_backend_path,
1233+ sysroot = args. config_info. sysroot_path,
1234+ extra = extra,
1235+ ) ;
1236+
1237+ env. get_mut ( "RUSTFLAGS" ) . unwrap ( ) . clear ( ) ;
1238+
1239+ let mut command: Vec < & dyn AsRef < OsStr > > = vec ! [
1240+ & "./x.py" ,
1241+ & "test" ,
1242+ & "--run" ,
1243+ & "always" ,
1244+ & "--stage" ,
1245+ & "0" ,
1246+ & "--set" ,
1247+ & "build.compiletest-allow-stage0=true" ,
1248+ & "--compiletest-rustc-args" ,
1249+ & rustc_args,
1250+ & "--bypass-ignore-backends" ,
1251+ ] ;
1252+
1253+ for test_name in & args. test_args {
1254+ command. push ( test_name) ;
1255+ }
1256+
1257+ run_command_with_output_and_env ( & command, Some ( & rust_path) , Some ( & env) ) ?;
1258+ Ok ( ( ) )
1259+ }
1260+
12211261fn retain_files_callback < ' a > (
12221262 file_path : & ' a str ,
12231263 test_type : & ' a str ,
0 commit comments