@@ -198,7 +198,7 @@ fn prepare_for_2018() {
198
198
}
199
199
200
200
#[ cargo_test]
201
- fn fix_tests ( ) {
201
+ fn do_not_fix_tests ( ) {
202
202
let p = project ( )
203
203
. file (
204
204
"src/lib.rs" ,
@@ -220,6 +220,87 @@ fn fix_tests() {
220
220
p. cargo ( "fix --allow-no-vcs" )
221
221
. with_stderr_data ( str![ [ r#"
222
222
[CHECKING] foo v0.0.1 ([ROOT]/foo)
223
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
224
+
225
+ "# ] ] )
226
+ . with_stdout_data ( "" )
227
+ . run ( ) ;
228
+ }
229
+
230
+ #[ cargo_test]
231
+ fn fix_tests_with_edition ( ) {
232
+ let p = project ( )
233
+ . file (
234
+ "Cargo.toml" ,
235
+ r#"
236
+ [package]
237
+ name = "foo"
238
+ version = "0.1.0"
239
+ edition = "2018"
240
+ "# ,
241
+ )
242
+ . file (
243
+ "src/lib.rs" ,
244
+ r#"
245
+ #![allow(ellipsis_inclusive_range_patterns)]
246
+ pub fn foo() {}
247
+
248
+ #[cfg(test)]
249
+ mod tests {
250
+ #[test]
251
+ fn it_works() {
252
+ f();
253
+ }
254
+ fn f() -> bool {
255
+ let x = 123;
256
+ match x {
257
+ 0...100 => true,
258
+ _ => false,
259
+ }
260
+ }
261
+ }
262
+ "# ,
263
+ )
264
+ . build ( ) ;
265
+
266
+ p. cargo ( "fix --edition --allow-no-vcs" )
267
+ . with_stderr_data ( str![ [ r#"
268
+ [MIGRATING] Cargo.toml from 2018 edition to 2021
269
+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
270
+ [MIGRATING] src/lib.rs from 2018 edition to 2021
271
+ [FIXED] src/lib.rs (1 fix)
272
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
273
+
274
+ "# ] ] )
275
+ . with_stdout_data ( "" )
276
+ . run ( ) ;
277
+ // Check that the test is fixed.
278
+ assert ! ( p. read_file( "src/lib.rs" ) . contains( r#"0..=100 => true,"# ) ) ;
279
+ }
280
+
281
+ #[ cargo_test]
282
+ fn fix_tests_with_edition_idioms ( ) {
283
+ let p = project ( )
284
+ . file (
285
+ "src/lib.rs" ,
286
+ r#"
287
+ pub fn foo() {}
288
+
289
+ #[cfg(test)]
290
+ mod tests {
291
+ #[test]
292
+ fn it_works() {
293
+ let mut x = 3;
294
+ x;
295
+ }
296
+ }
297
+ "# ,
298
+ )
299
+ . build ( ) ;
300
+
301
+ p. cargo ( "fix --edition-idioms --allow-no-vcs" )
302
+ . with_stderr_data ( str![ [ r#"
303
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
223
304
[FIXED] src/lib.rs (1 fix)
224
305
[WARNING] path statement with no effect
225
306
--> src/lib.rs:9:25
@@ -235,6 +316,8 @@ fn fix_tests() {
235
316
"# ] ] )
236
317
. with_stdout_data ( "" )
237
318
. run ( ) ;
319
+ // Check that the test is fixed.
320
+ assert ! ( !p. read_file( "src/lib.rs" ) . contains( "let mut x = 3;" ) ) ;
238
321
}
239
322
240
323
#[ cargo_test]
@@ -747,19 +830,6 @@ fn does_not_warn_about_dirty_ignored_files() {
747
830
p. cargo ( "fix" ) . run ( ) ;
748
831
}
749
832
750
- #[ cargo_test]
751
- fn fix_all_targets_by_default ( ) {
752
- let p = project ( )
753
- . file ( "src/lib.rs" , "pub fn foo() { let mut x = 3; let _ = x; }" )
754
- . file ( "tests/foo.rs" , "pub fn foo() { let mut x = 3; let _ = x; }" )
755
- . build ( ) ;
756
- p. cargo ( "fix --allow-no-vcs" )
757
- . env ( "__CARGO_FIX_YOLO" , "1" )
758
- . run ( ) ;
759
- assert ! ( !p. read_file( "src/lib.rs" ) . contains( "let mut x" ) ) ;
760
- assert ! ( !p. read_file( "tests/foo.rs" ) . contains( "let mut x" ) ) ;
761
- }
762
-
763
833
#[ cargo_test]
764
834
fn prepare_for_unstable ( ) {
765
835
// During the period where a new edition is coming up, but not yet stable,
@@ -1370,7 +1440,7 @@ fn fix_to_broken_code() {
1370
1440
p. cargo ( "fix --allow-no-vcs --broken-code" )
1371
1441
. cwd ( "bar" )
1372
1442
. env ( "RUSTC" , p. root ( ) . join ( "foo/target/debug/foo" ) )
1373
- . with_status ( 101 )
1443
+ . with_status ( 0 )
1374
1444
. with_stderr_data ( str![ [ r#"
1375
1445
...
1376
1446
[WARNING] failed to automatically apply fixes suggested by rustc to crate `bar`
0 commit comments