Skip to content

Commit 90a87be

Browse files
committed
make compose_and_run_compiler take Command
1 parent 0a666f8 commit 90a87be

File tree

1 file changed

+40
-52
lines changed

1 file changed

+40
-52
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -365,45 +365,35 @@ actual:\n\
365365
}
366366

367367
fn typecheck_source(&self, src: String) -> ProcRes {
368-
let args = self.make_typecheck_args();
369-
self.compose_and_run_compiler(args, Some(src))
370-
}
368+
let mut rustc = Command::new(&self.config.rustc_path);
369+
370+
let out_dir = self.output_base_name().with_extension("pretty-out");
371+
let _ = fs::remove_dir_all(&out_dir);
372+
create_dir_all(&out_dir).unwrap();
371373

372-
fn make_typecheck_args(&self) -> ProcArgs {
373-
let aux_dir = self.aux_output_dir_name();
374374
let target = if self.props.force_host {
375375
&*self.config.host
376376
} else {
377377
&*self.config.target
378378
};
379379

380-
let out_dir = self.output_base_name().with_extension("pretty-out");
381-
let _ = fs::remove_dir_all(&out_dir);
382-
create_dir_all(&out_dir).unwrap();
380+
let aux_dir = self.aux_output_dir_name();
381+
382+
rustc.arg("-")
383+
.arg("-Zno-trans")
384+
.arg("--out-dir").arg(&out_dir)
385+
.arg(&format!("--target={}", target))
386+
.arg("-L").arg(&self.config.build_base)
387+
.arg("-L").arg(aux_dir);
383388

384-
// FIXME (#9639): This needs to handle non-utf8 paths
385-
let mut args = vec!["-".to_owned(),
386-
"-Zno-trans".to_owned(),
387-
"--out-dir".to_owned(),
388-
out_dir.to_str().unwrap().to_owned(),
389-
format!("--target={}", target),
390-
"-L".to_owned(),
391-
self.config.build_base.to_str().unwrap().to_owned(),
392-
"-L".to_owned(),
393-
aux_dir.to_str().unwrap().to_owned()];
394389
if let Some(revision) = self.revision {
395-
args.extend(vec![
396-
"--cfg".to_string(),
397-
revision.to_string(),
398-
]);
399-
}
400-
args.extend(self.split_maybe_args(&self.config.target_rustcflags));
401-
args.extend(self.props.compile_flags.iter().cloned());
402-
// FIXME (#9639): This needs to handle non-utf8 paths
403-
ProcArgs {
404-
prog: self.config.rustc_path.to_str().unwrap().to_owned(),
405-
args,
390+
rustc.args(&["--cfg", revision]);
406391
}
392+
393+
rustc.args(self.split_maybe_args(&self.config.target_rustcflags));
394+
rustc.args(&self.props.compile_flags);
395+
396+
self.compose_and_run_compiler(rustc, Some(src))
407397
}
408398

409399
fn run_debuginfo_gdb_test(&self) {
@@ -1126,10 +1116,11 @@ actual:\n\
11261116
}
11271117
_ => {}
11281118
}
1129-
let args = self.make_compile_args(extra_args,
1130-
&self.testpaths.file,
1131-
TargetLocation::ThisFile(self.make_exe_name()));
1132-
self.compose_and_run_compiler(args, None)
1119+
let ProcArgs { prog, args } = self.make_compile_args(
1120+
extra_args, &self.testpaths.file, TargetLocation::ThisFile(self.make_exe_name()));
1121+
let mut rustc = Command::new(prog);
1122+
rustc.args(args);
1123+
self.compose_and_run_compiler(rustc, None)
11331124
}
11341125

11351126
fn document(&self, out_dir: &Path) -> ProcRes {
@@ -1153,18 +1144,16 @@ actual:\n\
11531144
}
11541145

11551146
let aux_dir = self.aux_output_dir_name();
1156-
let mut args = vec!["-L".to_owned(),
1157-
aux_dir.to_str().unwrap().to_owned(),
1158-
"-o".to_owned(),
1159-
out_dir.to_str().unwrap().to_owned(),
1160-
self.testpaths.file.to_str().unwrap().to_owned()];
1161-
args.extend(self.props.compile_flags.iter().cloned());
1162-
let args = ProcArgs {
1163-
prog: self.config.rustdoc_path
1164-
.as_ref().expect("--rustdoc-path passed").to_str().unwrap().to_owned(),
1165-
args,
1166-
};
1167-
self.compose_and_run_compiler(args, None)
1147+
1148+
let rustdoc_path = self.config.rustdoc_path.as_ref().expect("--rustdoc-path passed");
1149+
let mut rustdoc = Command::new(rustdoc_path);
1150+
1151+
rustdoc.arg("-L").arg(aux_dir)
1152+
.arg("-o").arg(out_dir)
1153+
.arg(&self.testpaths.file)
1154+
.args(&self.props.compile_flags);
1155+
1156+
self.compose_and_run_compiler(rustdoc, None)
11681157
}
11691158

11701159
fn exec_compiled_test(&self) -> ProcRes {
@@ -1247,7 +1236,7 @@ actual:\n\
12471236
}
12481237
}
12491238

1250-
fn compose_and_run_compiler(&self, args: ProcArgs, input: Option<String>) -> ProcRes {
1239+
fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
12511240
if !self.props.aux_builds.is_empty() {
12521241
create_dir_all(&self.aux_output_dir_name()).unwrap();
12531242
}
@@ -1307,11 +1296,7 @@ actual:\n\
13071296
}
13081297
}
13091298

1310-
let ProcArgs { prog, args } = args;
1311-
let mut rustc = Command::new(prog);
1312-
rustc.args(args)
1313-
.envs(self.props.rustc_env.clone());
1314-
1299+
rustc.envs(self.props.rustc_env.clone());
13151300
self.compose_and_run(rustc,
13161301
self.config.compile_lib_path.to_str().unwrap(),
13171302
Some(aux_dir.to_str().unwrap()),
@@ -1681,7 +1666,10 @@ actual:\n\
16811666
self.output_base_name().parent()
16821667
.unwrap()
16831668
.to_path_buf()));
1684-
self.compose_and_run_compiler(args, None)
1669+
let ProcArgs { prog, args } = args;
1670+
let mut rustc = Command::new(prog);
1671+
rustc.args(args);
1672+
self.compose_and_run_compiler(rustc, None)
16851673
}
16861674

16871675
fn check_ir_with_filecheck(&self) -> ProcRes {

0 commit comments

Comments
 (0)