Skip to content

Commit 2453a68

Browse files
committed
Add command to run specified UI tests
1 parent 1bb4b16 commit 2453a68

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

build_system/src/test.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
12211261
fn retain_files_callback<'a>(
12221262
file_path: &'a str,
12231263
test_type: &'a str,

0 commit comments

Comments
 (0)