Skip to content

Commit ac2f6cb

Browse files
committed
change sysroot check to print the output in case of an error
1 parent 965160d commit ac2f6cb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/bin/cargo-miri.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ fn test_sysroot_consistency() {
133133
fn get_sysroot(mut cmd: Command) -> PathBuf {
134134
let out = cmd.arg("--print").arg("sysroot")
135135
.output().expect("Failed to run rustc to get sysroot info");
136-
assert!(out.status.success(), "Bad status code when getting sysroot info");
137-
let sysroot = out.stdout.lines().nth(0)
138-
.expect("didn't get at least one line for the sysroot").unwrap();
139-
PathBuf::from(sysroot).canonicalize()
140-
.expect("Failed to canonicalize sysroot")
136+
let stdout = String::from_utf8(out.stdout).expect("stdout is not valid UTF-8");
137+
let stderr = String::from_utf8(out.stderr).expect("stderr is not valid UTF-8");
138+
let stdout = stdout.trim();
139+
assert!(out.status.success(), "Bad status code when getting sysroot info.\nstdout:\n{}\nstderr:\n{}", stdout, stderr);
140+
PathBuf::from(stdout).canonicalize()
141+
.unwrap_or_else(|_| panic!("Failed to canonicalize sysroot: {}", stdout))
141142
}
142143

143144
let rustc_sysroot = get_sysroot(Command::new("rustc"));

0 commit comments

Comments
 (0)