Skip to content

Commit

Permalink
Auto merge of #44680 - infinity0:master, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
rustbuild: with --no-fail-fast, report the specific commands that failed

I'm not sure this is the most elegant way of doing it, I'm still a bit of a rust noob. I tried `Vec<Command>` and keeping `Cell` instead of `RefCell` but couldn't fight my way past the borrow errors, this was the first arrangement that I could make work.
  • Loading branch information
bors committed Sep 18, 2017
2 parents 0701b37 + 8f25497 commit 06bb0e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl fmt::Display for TestKind {
fn try_run_expecting(build: &Build, cmd: &mut Command, expect: BuildExpectation) {
if !build.fail_fast {
if !build.try_run(cmd, expect) {
let failures = build.delayed_failures.get();
build.delayed_failures.set(failures + 1);
let mut failures = build.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd));
}
} else {
build.run_expecting(cmd, expect);
Expand All @@ -83,8 +83,8 @@ fn try_run(build: &Build, cmd: &mut Command) {
fn try_run_quiet(build: &Build, cmd: &mut Command) {
if !build.fail_fast {
if !build.try_run_quiet(cmd) {
let failures = build.delayed_failures.get();
build.delayed_failures.set(failures + 1);
let mut failures = build.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd));
}
} else {
build.run_quiet(cmd);
Expand Down
18 changes: 14 additions & 4 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ extern crate toml;
#[cfg(unix)]
extern crate libc;

use std::cell::Cell;
use std::cell::RefCell;
use std::collections::{HashSet, HashMap};
use std::env;
use std::fs::{self, File};
use std::io::Read;
use std::path::{PathBuf, Path};
use std::process::Command;
use std::process::{self, Command};
use std::slice;

use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime,
Expand Down Expand Up @@ -247,7 +247,7 @@ pub struct Build {
crates: HashMap<Interned<String>, Crate>,
is_sudo: bool,
ci_env: CiEnv,
delayed_failures: Cell<usize>,
delayed_failures: RefCell<Vec<String>>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -329,7 +329,7 @@ impl Build {
lldb_python_dir: None,
is_sudo,
ci_env: CiEnv::current(),
delayed_failures: Cell::new(0),
delayed_failures: RefCell::new(Vec::new()),
}
}

Expand Down Expand Up @@ -368,6 +368,16 @@ impl Build {
metadata::build(self);

builder::Builder::run(&self);

// Check for postponed failures from `test --no-fail-fast`.
let failures = self.delayed_failures.borrow();
if failures.len() > 0 {
println!("\n{} command(s) did not execute successfully:\n", failures.len());
for failure in failures.iter() {
println!(" - {}\n", failure);
}
process::exit(1);
}
}

/// Clear out `dir` if `input` is newer.
Expand Down

0 comments on commit 06bb0e0

Please sign in to comment.