Skip to content

Commit 06bb0e0

Browse files
committed
Auto merge of #44680 - infinity0:master, r=Mark-Simulacrum
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.
2 parents 0701b37 + 8f25497 commit 06bb0e0

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/bootstrap/check.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ impl fmt::Display for TestKind {
6868
fn try_run_expecting(build: &Build, cmd: &mut Command, expect: BuildExpectation) {
6969
if !build.fail_fast {
7070
if !build.try_run(cmd, expect) {
71-
let failures = build.delayed_failures.get();
72-
build.delayed_failures.set(failures + 1);
71+
let mut failures = build.delayed_failures.borrow_mut();
72+
failures.push(format!("{:?}", cmd));
7373
}
7474
} else {
7575
build.run_expecting(cmd, expect);
@@ -83,8 +83,8 @@ fn try_run(build: &Build, cmd: &mut Command) {
8383
fn try_run_quiet(build: &Build, cmd: &mut Command) {
8484
if !build.fail_fast {
8585
if !build.try_run_quiet(cmd) {
86-
let failures = build.delayed_failures.get();
87-
build.delayed_failures.set(failures + 1);
86+
let mut failures = build.delayed_failures.borrow_mut();
87+
failures.push(format!("{:?}", cmd));
8888
}
8989
} else {
9090
build.run_quiet(cmd);

src/bootstrap/lib.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ extern crate toml;
134134
#[cfg(unix)]
135135
extern crate libc;
136136

137-
use std::cell::Cell;
137+
use std::cell::RefCell;
138138
use std::collections::{HashSet, HashMap};
139139
use std::env;
140140
use std::fs::{self, File};
141141
use std::io::Read;
142142
use std::path::{PathBuf, Path};
143-
use std::process::Command;
143+
use std::process::{self, Command};
144144
use std::slice;
145145

146146
use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppressed, output, mtime,
@@ -247,7 +247,7 @@ pub struct Build {
247247
crates: HashMap<Interned<String>, Crate>,
248248
is_sudo: bool,
249249
ci_env: CiEnv,
250-
delayed_failures: Cell<usize>,
250+
delayed_failures: RefCell<Vec<String>>,
251251
}
252252

253253
#[derive(Debug)]
@@ -329,7 +329,7 @@ impl Build {
329329
lldb_python_dir: None,
330330
is_sudo,
331331
ci_env: CiEnv::current(),
332-
delayed_failures: Cell::new(0),
332+
delayed_failures: RefCell::new(Vec::new()),
333333
}
334334
}
335335

@@ -368,6 +368,16 @@ impl Build {
368368
metadata::build(self);
369369

370370
builder::Builder::run(&self);
371+
372+
// Check for postponed failures from `test --no-fail-fast`.
373+
let failures = self.delayed_failures.borrow();
374+
if failures.len() > 0 {
375+
println!("\n{} command(s) did not execute successfully:\n", failures.len());
376+
for failure in failures.iter() {
377+
println!(" - {}\n", failure);
378+
}
379+
process::exit(1);
380+
}
371381
}
372382

373383
/// Clear out `dir` if `input` is newer.

0 commit comments

Comments
 (0)