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 @@ -522,3 +522,35 @@ fn build_script_debug_assertions_override_dev() {
522522 // Dev profile with debug-assertions explicitly disabled
523523 p. cargo ( "build" ) . run ( ) ;
524524}
525+
526+ #[ cargo_test]
527+ fn build_script_debug_assertions_override_release ( ) {
528+ // Test that CARGO_CFG_DEBUG_ASSERTIONS respects profile overrides
529+ // Release profile with debug-assertions explicitly ENABLED
530+ let build_rs = r#"
531+ fn main() {
532+ let has_debug_assertions = std::env::var_os("CARGO_CFG_DEBUG_ASSERTIONS").is_some();
533+ assert!(has_debug_assertions, "CARGO_CFG_DEBUG_ASSERTIONS should be set when release profile enables it");
534+ }
535+ "# ;
536+
537+ let p = project ( )
538+ . file (
539+ "Cargo.toml" ,
540+ r#"
541+ [package]
542+ name = "foo"
543+ version = "0.1.0"
544+ edition = "2024"
545+
546+ [profile.release]
547+ debug-assertions = true
548+ "# ,
549+ )
550+ . file ( "src/lib.rs" , r#""# )
551+ . file ( "build.rs" , build_rs)
552+ . build ( ) ;
553+
554+ // Release profile with debug-assertions explicitly enabled
555+ p. cargo ( "build --release" ) . run ( ) ;
556+ }
You can’t perform that action at this time.
0 commit comments