Skip to content

Commit 76585f4

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 3acf2df commit 76585f4

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
@@ -44,6 +44,44 @@ Caused by:
4444
.run();
4545
}
4646

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

0 commit comments

Comments
 (0)