Skip to content

Commit 8c298d0

Browse files
committed
test(add): add test for CARGO_CFG_DEBUG_ASSERTIONS in dev profile
1 parent 5ca05d3 commit 8c298d0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/testsuite/build_script_env.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,22 @@ fn rerun_if_env_newly_added_in_config() {
452452
"#]])
453453
.run();
454454
}
455+
456+
#[cargo_test]
457+
fn build_script_debug_assertions_dev() {
458+
// Test that CARGO_CFG_DEBUG_ASSERTIONS is set in dev profile (default)
459+
let build_rs = r#"
460+
fn main() {
461+
let has_debug_assertions = std::env::var_os("CARGO_CFG_DEBUG_ASSERTIONS").is_some();
462+
assert!(has_debug_assertions, "CARGO_CFG_DEBUG_ASSERTIONS should be set in dev profile");
463+
}
464+
"#;
465+
466+
let p = project()
467+
.file("src/lib.rs", r#""#)
468+
.file("build.rs", build_rs)
469+
.build();
470+
471+
// Default dev profile has debug-assertions enabled
472+
p.cargo("check").run();
473+
}

0 commit comments

Comments
 (0)