@@ -31,16 +31,41 @@ mod test {
3131 fn setup ( ) {
3232 BUILD . call_once ( || {
3333 let mut command = Command :: new ( "cargo" ) ;
34- command. arg ( "build" ) . arg ( "--no-default-features" ) ;
35- #[ cfg( feature = "enum" ) ]
34+ command. arg ( "build" ) ;
35+
36+ #[ cfg( not( debug_assertions) ) ]
37+ command. arg ( "--release" ) ;
38+
39+ // Build features list dynamically based on compiled features
40+ // Note: Using vec_init_then_push pattern here is intentional due to conditional compilation
41+ #[ allow( clippy:: vec_init_then_push) ]
3642 {
37- command. arg ( "--features=enum" ) ;
43+ let mut features = vec ! [ ] ;
44+ #[ cfg( feature = "enum" ) ]
45+ features. push ( "enum" ) ;
46+ #[ cfg( feature = "closure" ) ]
47+ features. push ( "closure" ) ;
48+ #[ cfg( feature = "anyhow" ) ]
49+ features. push ( "anyhow" ) ;
50+ #[ cfg( feature = "runtime" ) ]
51+ features. push ( "runtime" ) ;
52+ #[ cfg( feature = "static" ) ]
53+ features. push ( "static" ) ;
54+
55+ if !features. is_empty ( ) {
56+ command. arg ( "--no-default-features" ) ;
57+ command. arg ( "--features" ) . arg ( features. join ( "," ) ) ;
58+ }
3859 }
39- assert ! ( command
40- . output( )
41- . expect( "failed to build extension" )
42- . status
43- . success( ) ) ;
60+
61+ let result = command. output ( ) . expect ( "failed to execute cargo build" ) ;
62+
63+ assert ! (
64+ result. status. success( ) ,
65+ "Extension build failed:\n stdout: {}\n stderr: {}" ,
66+ String :: from_utf8_lossy( & result. stdout) ,
67+ String :: from_utf8_lossy( & result. stderr)
68+ ) ;
4469 } ) ;
4570 }
4671
@@ -99,7 +124,12 @@ mod test {
99124 let mut path = env:: current_dir ( ) . expect ( "Could not get cwd" ) ;
100125 path. pop ( ) ;
101126 path. push ( "target" ) ;
127+
128+ #[ cfg( not( debug_assertions) ) ]
129+ path. push ( "release" ) ;
130+ #[ cfg( debug_assertions) ]
102131 path. push ( "debug" ) ;
132+
103133 path. push ( if std:: env:: consts:: DLL_EXTENSION == "dll" {
104134 "tests"
105135 } else {
0 commit comments