Skip to content

Commit

Permalink
add build script failure test when requesting backtraces
Browse files Browse the repository at this point in the history
it displays an additional message on how to improve these backtraces, now that
debuginfo is turned off most of the time in `dev.build-override`.
  • Loading branch information
lqd committed Oct 17, 2022
1 parent 3acf2df commit 76585f4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,44 @@ Caused by:
.run();
}

#[cargo_test]
fn custom_build_script_failed_backtraces_message() {
// In this situation (no dependency sharing), debuginfo is turned off in
// `dev.build-override`. However, if an error occurs running e.g. a build
// script, and backtraces are opted into: a message explaining how to
// improve backtraces is also displayed.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
authors = ["wycats@example.com"]
build = "build.rs"
"#,
)
.file("src/main.rs", "fn main() {}")
.file("build.rs", "fn main() { std::process::exit(101); }")
.build();
p.cargo("build -v")
.env("RUST_BACKTRACE", "1")
.with_status(101)
.with_stderr(
"\
[COMPILING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin [..]`
[RUNNING] `[..]/build-script-build`
[ERROR] failed to run custom build command for `foo v0.5.0 ([CWD])`
note: To improve backtraces for build dependencies[..]
Caused by:
process didn't exit successfully: `[..]/build-script-build` (exit [..]: 101)",
)
.run();
}

#[cargo_test]
fn custom_build_env_vars() {
let p = project()
Expand Down

0 comments on commit 76585f4

Please sign in to comment.