@@ -5,8 +5,8 @@ use cargo_test_support::compare::assert_match_exact;
55use  cargo_test_support:: git:: { self ,  init} ; 
66use  cargo_test_support:: paths:: { self ,  CargoPathExt } ; 
77use  cargo_test_support:: registry:: { Dependency ,  Package } ; 
8- use  cargo_test_support:: tools ; 
9- use  cargo_test_support:: { basic_manifest ,  is_nightly ,  project } ; 
8+ use  cargo_test_support:: { basic_manifest ,  is_nightly ,  project ,   Project } ; 
9+ use  cargo_test_support:: { tools ,  wrapped_clippy_driver } ; 
1010
1111#[ cargo_test]  
1212fn  do_not_fix_broken_builds ( )  { 
@@ -53,8 +53,7 @@ fn fix_broken_if_requested() {
5353        . run ( ) ; 
5454} 
5555
56- #[ cargo_test]  
57- fn  broken_fixes_backed_out ( )  { 
56+ fn  rustc_shim_for_cargo_fix ( )  -> Project  { 
5857    // This works as follows: 
5958    // - Create a `rustc` shim (the "foo" project) which will pretend that the 
6059    //   verification step fails. 
@@ -109,7 +108,6 @@ fn broken_fixes_backed_out() {
109108                            fs::File::create(&first).unwrap(); 
110109                        } 
111110                    } 
112- 
113111                    let status = Command::new("rustc") 
114112                        .args(env::args().skip(1)) 
115113                        .status() 
@@ -142,11 +140,60 @@ fn broken_fixes_backed_out() {
142140    // Build our rustc shim 
143141    p. cargo ( "build" ) . cwd ( "foo" ) . run ( ) ; 
144142
145-     // Attempt to fix code, but our shim will always fail the second compile 
143+     p
144+ } 
145+ 
146+ #[ cargo_test]  
147+ fn  broken_fixes_backed_out ( )  { 
148+     let  p = rustc_shim_for_cargo_fix ( ) ; 
149+     // Attempt to fix code, but our shim will always fail the second compile. 
150+     p. cargo ( "fix --allow-no-vcs --lib" ) 
151+         . cwd ( "bar" ) 
152+         . env ( "__CARGO_FIX_YOLO" ,  "1" ) 
153+         . env ( "RUSTC" ,  p. root ( ) . join ( "foo/target/debug/foo" ) ) 
154+         . with_stderr_contains ( 
155+             "warning: failed to automatically apply fixes suggested by rustc \  
156+ \n \ 
157+ \n \ 
158+ \ 
159+ \n \ 
160+ \n   \ 
161+ \n \ 
162+ \n \ 
163+ \n \ 
164+ \n \ 
165+ \n \ 
166+ \n \ 
167+ \n \ 
168+ \n \ 
169+ \n \ 
170+ \n \ 
171+ \n \ 
172+ \n \ 
173+ \n \ 
174+ , 
175+         ) 
176+         . with_stderr_contains ( "Original diagnostics will follow." ) 
177+         . with_stderr_contains ( "[WARNING] variable does not need to be mutable" ) 
178+         . with_stderr_does_not_contain ( "[..][FIXED][..]" ) 
179+         . run ( ) ; 
180+ 
181+     // Make sure the fix which should have been applied was backed out 
182+     assert ! ( p. read_file( "bar/src/lib.rs" ) . contains( "let mut x = 3;" ) ) ; 
183+ } 
184+ 
185+ #[ cargo_test]  
186+ fn  broken_clippy_fixes_backed_out ( )  { 
187+     let  p = rustc_shim_for_cargo_fix ( ) ; 
188+     // Attempt to fix code, but our shim will always fail the second compile. 
189+     // Also, we use `clippy` as a workspace wrapper to make sure that we properly 
190+     // generate the report bug text. 
146191    p. cargo ( "fix --allow-no-vcs --lib" ) 
147192        . cwd ( "bar" ) 
148193        . env ( "__CARGO_FIX_YOLO" ,  "1" ) 
149194        . env ( "RUSTC" ,  p. root ( ) . join ( "foo/target/debug/foo" ) ) 
195+         //  We can't use `clippy` so we use a `rustc` workspace wrapper instead 
196+         . env ( "RUSTC_WORKSPACE_WRAPPER" ,  wrapped_clippy_driver ( ) ) 
150197        . with_stderr_contains ( 
151198            "warning: failed to automatically apply fixes suggested by rustc \  
152199\n \ 
@@ -160,7 +207,7 @@ fn broken_fixes_backed_out() {
160207\n \ 
161208\n \ 
162209\n \ 
163- [..] \n \ 
210+ https://github.com/rust-lang/rust-clippy/issues \n \ 
164211\n \ 
165212\n \ 
166213\n \ 
0 commit comments