@@ -456,15 +456,16 @@ mod tests {
456456 i32.add
457457 )
458458)"# ;
459- let input_path = "/tmp/test_cli_input.wat" ;
460- let output_path = "/tmp/test_cli_output.wasm" ;
459+ let temp_dir = std:: env:: temp_dir ( ) ;
460+ let input_path = temp_dir. join ( "test_cli_input.wat" ) ;
461+ let output_path = temp_dir. join ( "test_cli_output.wasm" ) ;
461462
462- fs:: write ( input_path, input_wat) . unwrap ( ) ;
463+ fs:: write ( & input_path, input_wat) . unwrap ( ) ;
463464
464465 // Run optimization
465466 let result = optimize_command (
466- input_path. to_string ( ) ,
467- Some ( output_path. to_string ( ) ) ,
467+ input_path. to_string_lossy ( ) . to_string ( ) ,
468+ Some ( output_path. to_string_lossy ( ) . to_string ( ) ) ,
468469 false ,
469470 false ,
470471 false ,
@@ -473,14 +474,11 @@ mod tests {
473474 assert ! ( result. is_ok( ) , "Optimization should succeed" ) ;
474475
475476 // Check output exists
476- assert ! (
477- std:: path:: Path :: new( output_path) . exists( ) ,
478- "Output file should exist"
479- ) ;
477+ assert ! ( output_path. exists( ) , "Output file should exist" ) ;
480478
481479 // Clean up
482- let _ = fs:: remove_file ( input_path) ;
483- let _ = fs:: remove_file ( output_path) ;
480+ let _ = fs:: remove_file ( & input_path) ;
481+ let _ = fs:: remove_file ( & output_path) ;
484482 }
485483
486484 #[ test]
@@ -493,14 +491,15 @@ mod tests {
493491 i32.add
494492 )
495493)"# ;
496- let input_path = "/tmp/test_cli_stats_input.wat" ;
497- let output_path = "/tmp/test_cli_stats_output.wasm" ;
494+ let temp_dir = std:: env:: temp_dir ( ) ;
495+ let input_path = temp_dir. join ( "test_cli_stats_input.wat" ) ;
496+ let output_path = temp_dir. join ( "test_cli_stats_output.wasm" ) ;
498497
499- fs:: write ( input_path, input_wat) . unwrap ( ) ;
498+ fs:: write ( & input_path, input_wat) . unwrap ( ) ;
500499
501500 let result = optimize_command (
502- input_path. to_string ( ) ,
503- Some ( output_path. to_string ( ) ) ,
501+ input_path. to_string_lossy ( ) . to_string ( ) ,
502+ Some ( output_path. to_string_lossy ( ) . to_string ( ) ) ,
504503 false ,
505504 true , // Enable stats
506505 false ,
@@ -509,8 +508,8 @@ mod tests {
509508 assert ! ( result. is_ok( ) , "Optimization with stats should succeed" ) ;
510509
511510 // Clean up
512- let _ = fs:: remove_file ( input_path) ;
513- let _ = fs:: remove_file ( output_path) ;
511+ let _ = fs:: remove_file ( & input_path) ;
512+ let _ = fs:: remove_file ( & output_path) ;
514513 }
515514
516515 #[ test]
@@ -523,14 +522,15 @@ mod tests {
523522 i32.add
524523 )
525524)"# ;
526- let input_path = "/tmp/test_cli_verify_input.wat" ;
527- let output_path = "/tmp/test_cli_verify_output.wasm" ;
525+ let temp_dir = std:: env:: temp_dir ( ) ;
526+ let input_path = temp_dir. join ( "test_cli_verify_input.wat" ) ;
527+ let output_path = temp_dir. join ( "test_cli_verify_output.wasm" ) ;
528528
529- fs:: write ( input_path, input_wat) . unwrap ( ) ;
529+ fs:: write ( & input_path, input_wat) . unwrap ( ) ;
530530
531531 let result = optimize_command (
532- input_path. to_string ( ) ,
533- Some ( output_path. to_string ( ) ) ,
532+ input_path. to_string_lossy ( ) . to_string ( ) ,
533+ Some ( output_path. to_string_lossy ( ) . to_string ( ) ) ,
534534 false ,
535535 false ,
536536 true , // Enable verification
@@ -542,8 +542,8 @@ mod tests {
542542 ) ;
543543
544544 // Clean up
545- let _ = fs:: remove_file ( input_path) ;
546- let _ = fs:: remove_file ( output_path) ;
545+ let _ = fs:: remove_file ( & input_path) ;
546+ let _ = fs:: remove_file ( & output_path) ;
547547 }
548548
549549 #[ test]
@@ -556,14 +556,15 @@ mod tests {
556556 i32.add
557557 )
558558)"# ;
559- let input_path = "/tmp/test_cli_wat_output_input.wat" ;
560- let output_path = "/tmp/test_cli_wat_output_output.wat" ;
559+ let temp_dir = std:: env:: temp_dir ( ) ;
560+ let input_path = temp_dir. join ( "test_cli_wat_output_input.wat" ) ;
561+ let output_path = temp_dir. join ( "test_cli_wat_output_output.wat" ) ;
561562
562- fs:: write ( input_path, input_wat) . unwrap ( ) ;
563+ fs:: write ( & input_path, input_wat) . unwrap ( ) ;
563564
564565 let result = optimize_command (
565- input_path. to_string ( ) ,
566- Some ( output_path. to_string ( ) ) ,
566+ input_path. to_string_lossy ( ) . to_string ( ) ,
567+ Some ( output_path. to_string_lossy ( ) . to_string ( ) ) ,
567568 true , // WAT output
568569 false ,
569570 false ,
@@ -575,15 +576,15 @@ mod tests {
575576 ) ;
576577
577578 // Check that output is valid WAT
578- let output_content = fs:: read_to_string ( output_path) . unwrap ( ) ;
579+ let output_content = fs:: read_to_string ( & output_path) . unwrap ( ) ;
579580 assert ! (
580581 output_content. contains( "i32.const 300" ) ,
581582 "WAT should contain optimized constant 300"
582583 ) ;
583584
584585 // Clean up
585- let _ = fs:: remove_file ( input_path) ;
586- let _ = fs:: remove_file ( output_path) ;
586+ let _ = fs:: remove_file ( & input_path) ;
587+ let _ = fs:: remove_file ( & output_path) ;
587588 }
588589
589590 #[ test]
0 commit comments