4378: Add stderr to error message r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-05-08 16:54:38 +00:00 committed by GitHub
commit d81e19286f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -600,7 +600,12 @@ pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
fn output(mut cmd: Command) -> Result<Output> {
let output = cmd.output().with_context(|| format!("{:?} failed", cmd))?;
if !output.status.success() {
bail!("{:?} failed, {}", cmd, output.status)
match String::from_utf8(output.stderr) {
Ok(stderr) if !stderr.is_empty() => {
bail!("{:?} failed, {}\nstderr:\n{}", cmd, output.status, stderr)
}
_ => bail!("{:?} failed, {}", cmd, output.status),
}
}
Ok(output)
}