@@ -40,8 +40,7 @@ fn collect_bounds_from_dir(dir_path: &Path) -> Result<Vec<String>, Box<dyn std::
4040
4141 // Collect all items with their bounds
4242 for item in items. iter_all_items ( ) {
43- let label = item. to_string ( ) ;
44- all_bounds. push ( label) ;
43+ all_bounds. push ( item. to_string ( ) ) ;
4544 }
4645 }
4746
@@ -55,61 +54,52 @@ fn test_prune_trait_sandbox() -> Result<(), Box<dyn std::error::Error>> {
5554 let test_files_dir = Path :: new ( "tests/test_files/trait_sandbox" ) ;
5655 let expected_dir = Path :: new ( "tests/expected/trait_sandbox" ) ;
5756
58- // Verify test directories exist
59- assert ! (
60- test_files_dir. exists( ) ,
61- "Test files directory does not exist: {:?}" ,
62- test_files_dir
63- ) ;
64- assert ! (
65- expected_dir. exists( ) ,
66- "Expected directory does not exist: {:?}" ,
67- expected_dir
68- ) ;
57+ assert ! ( test_files_dir. exists( ) , "Missing {:?}" , test_files_dir) ;
58+ assert ! ( expected_dir. exists( ) , "Missing {:?}" , expected_dir) ;
6959
70- // Create temporary directory
60+ // Temporary working directory
7161 let temp_dir = TempDir :: new ( ) ?;
7262 let temp_path = temp_dir. path ( ) ;
73-
74- // Copy test files to temporary directory
7563 copy_dir_recursive ( test_files_dir, temp_path) ?;
7664
77- // Build the trait-winnower binary path
65+ // Ensure the binary exists
66+ Command :: new ( "cargo" )
67+ . args ( & [ "build" , "--bin" , "trait-winnower" ] )
68+ . status ( )
69+ . expect ( "Failed to build trait-winnower binary before running test" ) ;
70+
7871 let binary_path = if cfg ! ( debug_assertions) {
7972 "target/debug/trait-winnower"
8073 } else {
8174 "target/release/trait-winnower"
8275 } ;
8376
84- // Run trait-winnower prune command
77+ // Run the prune command
8578 let output = Command :: new ( binary_path)
8679 . args ( & [ "prune" , "-n" , "all" , "-t" , "all" , "--brute-force" ] )
8780 . arg ( temp_path)
8881 . output ( ) ?;
8982
90- // Check if command succeeded
9183 assert ! (
9284 output. status. success( ) ,
93- "trait-winnower prune failed with status : {}\n stdout: {}\n stderr: {}" ,
85+ "trait-winnower prune failed\n status : {}\n stdout:\n {}\n stderr:\n {}" ,
9486 output. status,
9587 String :: from_utf8_lossy( & output. stdout) ,
96- String :: from_utf8_lossy( & output. stderr)
88+ String :: from_utf8_lossy( & output. stderr) ,
9789 ) ;
9890
99- // Collect bounds from the pruned directory
91+ // Compare the collected bounds
10092 let pruned_bounds = collect_bounds_from_dir ( temp_path) ?;
101-
102- // Collect bounds from the expected directory
10393 let expected_bounds = collect_bounds_from_dir ( expected_dir) ?;
10494
105- // Compare bounds
10695 assert_eq ! (
10796 pruned_bounds. len( ) ,
10897 expected_bounds. len( ) ,
10998 "Number of bounds differs. Pruned: {}, Expected: {}" ,
11099 pruned_bounds. len( ) ,
111100 expected_bounds. len( )
112101 ) ;
102+
113103 for ( i, ( pruned, expected) ) in pruned_bounds. iter ( ) . zip ( expected_bounds. iter ( ) ) . enumerate ( ) {
114104 assert_eq ! (
115105 pruned, expected,
@@ -118,6 +108,6 @@ fn test_prune_trait_sandbox() -> Result<(), Box<dyn std::error::Error>> {
118108 ) ;
119109 }
120110
121- println ! ( "All bounds and file contents match expected results!" ) ;
111+ println ! ( "[+] All bounds and file contents match expected results!" ) ;
122112 Ok ( ( ) )
123- }
113+ }
0 commit comments