Skip to content

Commit 875c0fb

Browse files
committed
test(add): Add test CARGO_CFG_DEBUG_ASSERTIONS is set in release profile
1 parent bf5fa9f commit 875c0fb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/testsuite/build_script_env.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,23 @@ fn build_script_debug_assertions_dev() {
472472
p.cargo("build")
473473
.run();
474474
}
475+
476+
#[cargo_test]
477+
fn build_script_debug_assertions_release() {
478+
// Test that CARGO_CFG_DEBUG_ASSERTIONS is NOT set in release profile (default)
479+
let build_rs = r#"
480+
fn main() {
481+
let has_debug_assertions = std::env::var_os("CARGO_CFG_DEBUG_ASSERTIONS").is_some();
482+
assert!(!has_debug_assertions, "CARGO_CFG_DEBUG_ASSERTIONS should NOT be set in release profile");
483+
}
484+
"#;
485+
486+
let p = project()
487+
.file("src/lib.rs", r#""#)
488+
.file("build.rs", build_rs)
489+
.build();
490+
491+
// Release profile has debug-assertions disabled by default
492+
p.cargo("build --release")
493+
.run();
494+
}

0 commit comments

Comments
 (0)