Skip to content

Commit 425acd5

Browse files
committed
add build script failure test when requesting backtraces
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`.
1 parent 58e6599 commit 425acd5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/testsuite/build_script.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,44 @@ Caused by:
4646
.run();
4747
}
4848

49+
#[cargo_test]
50+
fn custom_build_script_failed_backtraces_message() {
51+
// In this situation (no dependency sharing), debuginfo is turned off in
52+
// `dev.build-override`. However, if an error occurs running e.g. a build
53+
// script, and backtraces are opted into: a message explaining how to
54+
// improve backtraces is also displayed.
55+
let p = project()
56+
.file(
57+
"Cargo.toml",
58+
r#"
59+
[package]
60+
61+
name = "foo"
62+
version = "0.5.0"
63+
authors = ["wycats@example.com"]
64+
build = "build.rs"
65+
"#,
66+
)
67+
.file("src/main.rs", "fn main() {}")
68+
.file("build.rs", "fn main() { std::process::exit(101); }")
69+
.build();
70+
p.cargo("build -v")
71+
.env("RUST_BACKTRACE", "1")
72+
.with_status(101)
73+
.with_stderr(
74+
"\
75+
[COMPILING] foo v0.5.0 ([CWD])
76+
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin [..]`
77+
[RUNNING] `[..]/build-script-build`
78+
[ERROR] failed to run custom build command for `foo v0.5.0 ([CWD])`
79+
note: To improve backtraces for build dependencies[..]
80+
81+
Caused by:
82+
process didn't exit successfully: `[..]/build-script-build` (exit [..]: 101)",
83+
)
84+
.run();
85+
}
86+
4987
#[cargo_test]
5088
fn custom_build_env_vars() {
5189
let p = project()

0 commit comments

Comments
 (0)