Skip to content

Commit 90d4e7a

Browse files
committed
test(add): Add test CARGO_CFG_DEBUG_ASSERTIONS is set in release profile
1 parent 8c298d0 commit 90d4e7a

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
@@ -471,3 +471,22 @@ fn build_script_debug_assertions_dev() {
471471
// Default dev profile has debug-assertions enabled
472472
p.cargo("check").run();
473473
}
474+
475+
#[cargo_test]
476+
fn build_script_debug_assertions_release() {
477+
// Test that CARGO_CFG_DEBUG_ASSERTIONS is NOT set in release profile (default)
478+
let build_rs = r#"
479+
fn main() {
480+
let has_debug_assertions = std::env::var_os("CARGO_CFG_DEBUG_ASSERTIONS").is_some();
481+
assert!(!has_debug_assertions, "CARGO_CFG_DEBUG_ASSERTIONS should NOT be set in release profile");
482+
}
483+
"#;
484+
485+
let p = project()
486+
.file("src/lib.rs", r#""#)
487+
.file("build.rs", build_rs)
488+
.build();
489+
490+
// Release profile has debug-assertions disabled by default
491+
p.cargo("check --release").run();
492+
}

0 commit comments

Comments
 (0)