@@ -39,7 +39,7 @@ fn compile_and_get_json_errors(file: &Path) -> Result<String, Box<Error>> {
39
39
40
40
use std:: io:: { Error , ErrorKind } ;
41
41
match res. status . code ( ) {
42
- Some ( 0 ) | Some ( 1 ) => Ok ( stderr) ,
42
+ Some ( 0 ) | Some ( 1 ) | Some ( 101 ) => Ok ( stderr) ,
43
43
_ => Err ( Box :: new ( Error :: new (
44
44
ErrorKind :: Other ,
45
45
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>> {
122
122
let json_file = file. with_extension ( "json" ) ;
123
123
let fixed_file = file. with_extension ( "fixed.rs" ) ;
124
124
125
- debug ! ( "{:?}" , file) ;
125
+ debug ! ( "next up: {:?}" , file) ;
126
126
let code = read_file ( file) ?;
127
127
let errors = compile_and_get_json_errors ( file) ?;
128
128
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>> {
143
143
144
144
let mut fixed = code. clone ( ) ;
145
145
146
- for sug in suggestions {
146
+ for sug in suggestions. into_iter ( ) . rev ( ) {
147
147
trace ! ( "{:?}" , sug) ;
148
148
for sol in sug. solutions {
149
149
trace ! ( "{:?}" , sol) ;
@@ -155,6 +155,12 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P) -> Result<(), Box<Error>> {
155
155
}
156
156
}
157
157
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
+
158
164
let expected_fixed = read_file ( & fixed_file) ?;
159
165
assert_eq ! ( fixed. trim( ) , expected_fixed. trim( ) , "file doesn't look fixed" ) ;
160
166
@@ -170,7 +176,7 @@ fn get_fixture_files() -> Result<Vec<PathBuf>, Box<Error>> {
170
176
. filter ( |p| p. is_file ( ) )
171
177
. filter ( |p| {
172
178
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" )
174
180
} )
175
181
. collect ( ) )
176
182
}
0 commit comments