Skip to content

Commit d5f1078

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 by default in `dev.build-override`.
1 parent 835978b commit d5f1078

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/testsuite/build_script.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,43 @@ Caused by:
4444
.run();
4545
}
4646

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

0 commit comments

Comments
 (0)