Skip to content

Commit 4668751

Browse files
committed
Print what bootstrap invocation failed when an error happens in CI
1 parent 425a9c0 commit 4668751

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/build_helper/src/util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::io::{BufRead, BufReader};
33
use std::path::Path;
44
use std::process::Command;
55

6+
use crate::ci::CiEnv;
7+
68
/// Invokes `build_helper::util::detail_exit` with `cfg!(test)`
79
///
810
/// This is a macro instead of a function so that it uses `cfg(test)` in the *calling* crate, not in build helper.
@@ -20,6 +22,15 @@ pub fn detail_exit(code: i32, is_test: bool) -> ! {
2022
if is_test {
2123
panic!("status code: {code}");
2224
} else {
25+
// If we're in CI, print the current bootstrap invocation command, to make it easier to
26+
// figure out what exactly has failed.
27+
if CiEnv::is_ci() {
28+
// Skip the first argument, as it will be some absolute path to the bootstrap binary.
29+
let bootstrap_args =
30+
std::env::args().skip(1).map(|a| a.to_string()).collect::<Vec<_>>().join(" ");
31+
eprintln!("Bootstrap failed while executing `{bootstrap_args}`");
32+
}
33+
2334
// otherwise, exit with provided status code
2435
std::process::exit(code);
2536
}

0 commit comments

Comments
 (0)