@@ -234,16 +234,13 @@ mod tests {
234234 }
235235 }
236236
237- fn cleanup ( out_file_path : & str , cmd_file_path : & str ) -> Result < ( ) > {
238- let res1 = std:: fs:: remove_file ( out_file_path)
239- . map_err ( |e| new_error ! ( "Failed to remove gdb.output file: {}" , e) ) ;
240- let res2 = std:: fs:: remove_file ( cmd_file_path)
241- . map_err ( |e| new_error ! ( "Failed to remove gdb-commands.txt file: {}" , e) ) ;
242-
243- res1?;
244- res2?;
245-
246- Ok ( ( ) )
237+ fn cleanup ( out_file_path : & str , cmd_file_path : & str ) {
238+ // Ignore missing files — they may not exist if the test failed early.
239+ for path in [ out_file_path, cmd_file_path] {
240+ if let Err ( e) = std:: fs:: remove_file ( path) {
241+ println ! ( "Warning: failed to remove {} during cleanup: {}" , path, e) ;
242+ }
243+ }
247244 }
248245
249246 #[ test]
@@ -286,10 +283,7 @@ mod tests {
286283
287284 let result = run_guest_and_gdb ( & cmd_file_path, & out_file_path, & cmd, checker) ;
288285
289- // cleanup
290- let cleanup_result = cleanup ( & out_file_path, & cmd_file_path) ;
291- assert ! ( cleanup_result. is_ok( ) , "{}" , cleanup_result. unwrap_err( ) ) ;
292- // check if the test passed - done at the end to ensure cleanup is done
286+ cleanup ( & out_file_path, & cmd_file_path) ;
293287 assert ! ( result. is_ok( ) , "{}" , result. unwrap_err( ) ) ;
294288 }
295289
@@ -337,10 +331,7 @@ mod tests {
337331 let checker = |contents : String | contents. contains ( "$2 = [1.20000005, 0, 0, 0]" ) ;
338332 let result = run_guest_and_gdb ( & cmd_file_path, & out_file_path, & cmd, checker) ;
339333
340- // cleanup
341- let cleanup_result = cleanup ( & out_file_path, & cmd_file_path) ;
342- assert ! ( cleanup_result. is_ok( ) , "{}" , cleanup_result. unwrap_err( ) ) ;
343- // check if the test passed - done at the end to ensure cleanup is done
334+ cleanup ( & out_file_path, & cmd_file_path) ;
344335 assert ! ( result. is_ok( ) , "{}" , result. unwrap_err( ) ) ;
345336 }
346337}
0 commit comments