File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -490,3 +490,35 @@ fn build_script_debug_assertions_release() {
490490 // Release profile has debug-assertions disabled by default
491491 p. cargo ( "build --release" ) . run ( ) ;
492492}
493+
494+ #[ cargo_test]
495+ fn build_script_debug_assertions_override_dev ( ) {
496+ // Test that CARGO_CFG_DEBUG_ASSERTIONS respects profile overrides
497+ // Dev profile with debug-assertions explicitly DISABLED
498+ let build_rs = r#"
499+ fn main() {
500+ let has_debug_assertions = std::env::var_os("CARGO_CFG_DEBUG_ASSERTIONS").is_some();
501+ assert!(!has_debug_assertions, "CARGO_CFG_DEBUG_ASSERTIONS should NOT be set when dev profile disables it");
502+ }
503+ "# ;
504+
505+ let p = project ( )
506+ . file (
507+ "Cargo.toml" ,
508+ r#"
509+ [package]
510+ name = "foo"
511+ version = "0.1.0"
512+ edition = "2024"
513+
514+ [profile.dev]
515+ debug-assertions = false
516+ "# ,
517+ )
518+ . file ( "src/lib.rs" , r#""# )
519+ . file ( "build.rs" , build_rs)
520+ . build ( ) ;
521+
522+ // Dev profile with debug-assertions explicitly disabled
523+ p. cargo ( "build" ) . run ( ) ;
524+ }
You can’t perform that action at this time.
0 commit comments