Skip to content

Commit 7dfabdc

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 881533b commit 7dfabdc

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
@@ -47,6 +47,44 @@ Caused by:
4747
.run();
4848
}
4949

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

0 commit comments

Comments
 (0)