Skip to content

Commit 1a99015

Browse files
committed
run-make-support: make handle_failed_output take a &Command
1 parent 033becf commit 1a99015

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/tools/run-make-support/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
8282
cygpath.arg(path.as_ref());
8383
let output = cygpath.output().unwrap();
8484
if !output.status.success() {
85-
handle_failed_output(&format!("{:#?}", cygpath), output, caller_line_number);
85+
handle_failed_output(&cygpath, output, caller_line_number);
8686
}
8787
let s = String::from_utf8(output.stdout).unwrap();
8888
// cygpath -w can attach a newline
@@ -98,18 +98,18 @@ pub fn uname() -> String {
9898
let mut uname = Command::new("uname");
9999
let output = uname.output().unwrap();
100100
if !output.status.success() {
101-
handle_failed_output(&format!("{:#?}", uname), output, caller_line_number);
101+
handle_failed_output(&uname, output, caller_line_number);
102102
}
103103
String::from_utf8(output.stdout).unwrap()
104104
}
105105

106-
fn handle_failed_output(cmd: &str, output: Output, caller_line_number: u32) -> ! {
106+
fn handle_failed_output(cmd: &Command, output: Output, caller_line_number: u32) -> ! {
107107
if output.status.success() {
108-
eprintln!("command incorrectly succeeded at line {caller_line_number}");
108+
eprintln!("command unexpectedly succeeded at line {caller_line_number}");
109109
} else {
110110
eprintln!("command failed at line {caller_line_number}");
111111
}
112-
eprintln!("{cmd}");
112+
eprintln!("{cmd:?}");
113113
eprintln!("output status: `{}`", output.status);
114114
eprintln!("=== STDOUT ===\n{}\n\n", String::from_utf8(output.stdout).unwrap());
115115
eprintln!("=== STDERR ===\n{}\n\n", String::from_utf8(output.stderr).unwrap());

src/tools/run-make-support/src/run.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn run(name: &str) -> Output {
4545

4646
let (cmd, output) = run_common(name);
4747
if !output.status.success() {
48-
handle_failed_output(&format!("{:#?}", cmd), output, caller_line_number);
48+
handle_failed_output(&cmd, output, caller_line_number);
4949
}
5050
output
5151
}
@@ -58,7 +58,7 @@ pub fn run_fail(name: &str) -> Output {
5858

5959
let (cmd, output) = run_common(name);
6060
if output.status.success() {
61-
handle_failed_output(&format!("{:#?}", cmd), output, caller_line_number);
61+
handle_failed_output(&cmd, output, caller_line_number);
6262
}
6363
output
6464
}

0 commit comments

Comments
 (0)