run-make-support: make handle_failed_output
take a &Command
This commit is contained in:
parent
7106800e16
commit
e994534242
@ -82,7 +82,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
|
|||||||
cygpath.arg(path.as_ref());
|
cygpath.arg(path.as_ref());
|
||||||
let output = cygpath.output().unwrap();
|
let output = cygpath.output().unwrap();
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
handle_failed_output(&format!("{:#?}", cygpath), output, caller_line_number);
|
handle_failed_output(&cygpath, output, caller_line_number);
|
||||||
}
|
}
|
||||||
let s = String::from_utf8(output.stdout).unwrap();
|
let s = String::from_utf8(output.stdout).unwrap();
|
||||||
// cygpath -w can attach a newline
|
// cygpath -w can attach a newline
|
||||||
@ -98,18 +98,18 @@ pub fn uname() -> String {
|
|||||||
let mut uname = Command::new("uname");
|
let mut uname = Command::new("uname");
|
||||||
let output = uname.output().unwrap();
|
let output = uname.output().unwrap();
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
handle_failed_output(&format!("{:#?}", uname), output, caller_line_number);
|
handle_failed_output(&uname, output, caller_line_number);
|
||||||
}
|
}
|
||||||
String::from_utf8(output.stdout).unwrap()
|
String::from_utf8(output.stdout).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_failed_output(cmd: &str, output: Output, caller_line_number: u32) -> ! {
|
fn handle_failed_output(cmd: &Command, output: Output, caller_line_number: u32) -> ! {
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
eprintln!("command incorrectly succeeded at line {caller_line_number}");
|
eprintln!("command unexpectedly succeeded at line {caller_line_number}");
|
||||||
} else {
|
} else {
|
||||||
eprintln!("command failed at line {caller_line_number}");
|
eprintln!("command failed at line {caller_line_number}");
|
||||||
}
|
}
|
||||||
eprintln!("{cmd}");
|
eprintln!("{cmd:?}");
|
||||||
eprintln!("output status: `{}`", output.status);
|
eprintln!("output status: `{}`", output.status);
|
||||||
eprintln!("=== STDOUT ===\n{}\n\n", String::from_utf8(output.stdout).unwrap());
|
eprintln!("=== STDOUT ===\n{}\n\n", String::from_utf8(output.stdout).unwrap());
|
||||||
eprintln!("=== STDERR ===\n{}\n\n", String::from_utf8(output.stderr).unwrap());
|
eprintln!("=== STDERR ===\n{}\n\n", String::from_utf8(output.stderr).unwrap());
|
||||||
|
@ -45,7 +45,7 @@ pub fn run(name: &str) -> Output {
|
|||||||
|
|
||||||
let (cmd, output) = run_common(name);
|
let (cmd, output) = run_common(name);
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
handle_failed_output(&format!("{:#?}", cmd), output, caller_line_number);
|
handle_failed_output(&cmd, output, caller_line_number);
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ pub fn run_fail(name: &str) -> Output {
|
|||||||
|
|
||||||
let (cmd, output) = run_common(name);
|
let (cmd, output) = run_common(name);
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
handle_failed_output(&format!("{:#?}", cmd), output, caller_line_number);
|
handle_failed_output(&cmd, output, caller_line_number);
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ impl Rustc {
|
|||||||
|
|
||||||
let output = self.cmd.output().unwrap();
|
let output = self.cmd.output().unwrap();
|
||||||
if output.status.code().unwrap() != code {
|
if output.status.code().unwrap() != code {
|
||||||
handle_failed_output(&format!("{:#?}", self.cmd), output, caller_line_number);
|
handle_failed_output(&self.cmd, output, caller_line_number);
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ impl Rustdoc {
|
|||||||
|
|
||||||
let output = self.cmd.output().unwrap();
|
let output = self.cmd.output().unwrap();
|
||||||
if output.status.code().unwrap() != code {
|
if output.status.code().unwrap() != code {
|
||||||
handle_failed_output(&format!("{:#?}", self.cmd), output, caller_line_number);
|
handle_failed_output(&self.cmd, output, caller_line_number);
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user