make compose_and_run_compiler take Command

This commit is contained in:
Andy Russell 2017-08-10 15:18:00 -04:00
parent 0a666f87ca
commit 90a87be9cb
No known key found for this signature in database
GPG Key ID: 78B13E28497AF2DF

View File

@ -365,45 +365,35 @@ actual:\n\
} }
fn typecheck_source(&self, src: String) -> ProcRes { fn typecheck_source(&self, src: String) -> ProcRes {
let args = self.make_typecheck_args(); let mut rustc = Command::new(&self.config.rustc_path);
self.compose_and_run_compiler(args, Some(src))
} let out_dir = self.output_base_name().with_extension("pretty-out");
let _ = fs::remove_dir_all(&out_dir);
create_dir_all(&out_dir).unwrap();
fn make_typecheck_args(&self) -> ProcArgs {
let aux_dir = self.aux_output_dir_name();
let target = if self.props.force_host { let target = if self.props.force_host {
&*self.config.host &*self.config.host
} else { } else {
&*self.config.target &*self.config.target
}; };
let out_dir = self.output_base_name().with_extension("pretty-out"); let aux_dir = self.aux_output_dir_name();
let _ = fs::remove_dir_all(&out_dir);
create_dir_all(&out_dir).unwrap(); rustc.arg("-")
.arg("-Zno-trans")
.arg("--out-dir").arg(&out_dir)
.arg(&format!("--target={}", target))
.arg("-L").arg(&self.config.build_base)
.arg("-L").arg(aux_dir);
// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!["-".to_owned(),
"-Zno-trans".to_owned(),
"--out-dir".to_owned(),
out_dir.to_str().unwrap().to_owned(),
format!("--target={}", target),
"-L".to_owned(),
self.config.build_base.to_str().unwrap().to_owned(),
"-L".to_owned(),
aux_dir.to_str().unwrap().to_owned()];
if let Some(revision) = self.revision { if let Some(revision) = self.revision {
args.extend(vec![ rustc.args(&["--cfg", revision]);
"--cfg".to_string(),
revision.to_string(),
]);
}
args.extend(self.split_maybe_args(&self.config.target_rustcflags));
args.extend(self.props.compile_flags.iter().cloned());
// FIXME (#9639): This needs to handle non-utf8 paths
ProcArgs {
prog: self.config.rustc_path.to_str().unwrap().to_owned(),
args,
} }
rustc.args(self.split_maybe_args(&self.config.target_rustcflags));
rustc.args(&self.props.compile_flags);
self.compose_and_run_compiler(rustc, Some(src))
} }
fn run_debuginfo_gdb_test(&self) { fn run_debuginfo_gdb_test(&self) {
@ -1126,10 +1116,11 @@ actual:\n\
} }
_ => {} _ => {}
} }
let args = self.make_compile_args(extra_args, let ProcArgs { prog, args } = self.make_compile_args(
&self.testpaths.file, extra_args, &self.testpaths.file, TargetLocation::ThisFile(self.make_exe_name()));
TargetLocation::ThisFile(self.make_exe_name())); let mut rustc = Command::new(prog);
self.compose_and_run_compiler(args, None) rustc.args(args);
self.compose_and_run_compiler(rustc, None)
} }
fn document(&self, out_dir: &Path) -> ProcRes { fn document(&self, out_dir: &Path) -> ProcRes {
@ -1153,18 +1144,16 @@ actual:\n\
} }
let aux_dir = self.aux_output_dir_name(); let aux_dir = self.aux_output_dir_name();
let mut args = vec!["-L".to_owned(),
aux_dir.to_str().unwrap().to_owned(), let rustdoc_path = self.config.rustdoc_path.as_ref().expect("--rustdoc-path passed");
"-o".to_owned(), let mut rustdoc = Command::new(rustdoc_path);
out_dir.to_str().unwrap().to_owned(),
self.testpaths.file.to_str().unwrap().to_owned()]; rustdoc.arg("-L").arg(aux_dir)
args.extend(self.props.compile_flags.iter().cloned()); .arg("-o").arg(out_dir)
let args = ProcArgs { .arg(&self.testpaths.file)
prog: self.config.rustdoc_path .args(&self.props.compile_flags);
.as_ref().expect("--rustdoc-path passed").to_str().unwrap().to_owned(),
args, self.compose_and_run_compiler(rustdoc, None)
};
self.compose_and_run_compiler(args, None)
} }
fn exec_compiled_test(&self) -> ProcRes { fn exec_compiled_test(&self) -> ProcRes {
@ -1247,7 +1236,7 @@ actual:\n\
} }
} }
fn compose_and_run_compiler(&self, args: ProcArgs, input: Option<String>) -> ProcRes { fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
if !self.props.aux_builds.is_empty() { if !self.props.aux_builds.is_empty() {
create_dir_all(&self.aux_output_dir_name()).unwrap(); create_dir_all(&self.aux_output_dir_name()).unwrap();
} }
@ -1307,11 +1296,7 @@ actual:\n\
} }
} }
let ProcArgs { prog, args } = args; rustc.envs(self.props.rustc_env.clone());
let mut rustc = Command::new(prog);
rustc.args(args)
.envs(self.props.rustc_env.clone());
self.compose_and_run(rustc, self.compose_and_run(rustc,
self.config.compile_lib_path.to_str().unwrap(), self.config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()), Some(aux_dir.to_str().unwrap()),
@ -1681,7 +1666,10 @@ actual:\n\
self.output_base_name().parent() self.output_base_name().parent()
.unwrap() .unwrap()
.to_path_buf())); .to_path_buf()));
self.compose_and_run_compiler(args, None) let ProcArgs { prog, args } = args;
let mut rustc = Command::new(prog);
rustc.args(args);
self.compose_and_run_compiler(rustc, None)
} }
fn check_ir_with_filecheck(&self) -> ProcRes { fn check_ir_with_filecheck(&self) -> ProcRes {