@@ -39,7 +39,7 @@ fn compile_and_get_json_errors(file: &Path) -> Result<String, Box<Error>> {
3939
4040 use std:: io:: { Error , ErrorKind } ;
4141 match res. status . code ( ) {
42- Some ( 0 ) | Some ( 1 ) => Ok ( stderr) ,
42+ Some ( 0 ) | Some ( 1 ) | Some ( 101 ) => Ok ( stderr) ,
4343 _ => Err ( Box :: new ( Error :: new (
4444 ErrorKind :: Other ,
4545 format ! ( "failed with status {:?}: {}" , res. status. code( ) , stderr) ,
@@ -122,7 +122,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P) -> Result<(), Box<Error>> {
122122 let json_file = file. with_extension ( "json" ) ;
123123 let fixed_file = file. with_extension ( "fixed.rs" ) ;
124124
125- debug ! ( "{:?}" , file) ;
125+ debug ! ( "next up: {:?}" , file) ;
126126 let code = read_file ( file) ?;
127127 let errors = compile_and_get_json_errors ( file) ?;
128128 let suggestions = rustfix:: get_suggestions_from_json ( & errors, & HashSet :: new ( ) ) ;
@@ -143,7 +143,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P) -> Result<(), Box<Error>> {
143143
144144 let mut fixed = code. clone ( ) ;
145145
146- for sug in suggestions {
146+ for sug in suggestions. into_iter ( ) . rev ( ) {
147147 trace ! ( "{:?}" , sug) ;
148148 for sol in sug. solutions {
149149 trace ! ( "{:?}" , sol) ;
@@ -155,6 +155,12 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P) -> Result<(), Box<Error>> {
155155 }
156156 }
157157
158+ if std:: env:: var ( "RUSTFIX_TEST_RECORD_FIXED_RUST" ) . is_ok ( ) {
159+ use std:: io:: Write ;
160+ let mut recorded_rust = fs:: File :: create ( & file. with_extension ( "recorded.rs" ) ) ?;
161+ recorded_rust. write_all ( fixed. as_bytes ( ) ) ?;
162+ }
163+
158164 let expected_fixed = read_file ( & fixed_file) ?;
159165 assert_eq ! ( fixed. trim( ) , expected_fixed. trim( ) , "file doesn't look fixed" ) ;
160166
@@ -170,7 +176,7 @@ fn get_fixture_files() -> Result<Vec<PathBuf>, Box<Error>> {
170176 . filter ( |p| p. is_file ( ) )
171177 . filter ( |p| {
172178 let x = p. to_string_lossy ( ) ;
173- x. ends_with ( ".rs" ) && !x. ends_with ( ".fixed.rs" )
179+ x. ends_with ( ".rs" ) && !x. ends_with ( ".fixed.rs" ) && !x . ends_with ( ".recorded.rs" )
174180 } )
175181 . collect ( ) )
176182}
0 commit comments