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