14
14
//! The [`expect_fix_runs_rustc_n_times`] function handles setting everything
15
15
//! up, and verifying the results.
16
16
17
- #![ allow( deprecated) ]
18
-
19
- use cargo_test_support:: { basic_manifest, paths, project, tools, Execs } ;
17
+ use cargo_test_support:: { basic_manifest, paths, project, str, tools, Execs } ;
18
+ use snapbox:: data:: Inline ;
20
19
use std:: path:: PathBuf ;
21
20
use std:: sync:: { Mutex , OnceLock } ;
22
21
@@ -60,7 +59,7 @@ enum Step {
60
59
fn expect_fix_runs_rustc_n_times (
61
60
sequence : & [ Step ] ,
62
61
extra_execs : impl FnOnce ( & mut Execs ) ,
63
- expected_stderr : & str ,
62
+ expected_stderr : Inline ,
64
63
expected_lib_rs : & str ,
65
64
) {
66
65
let rustc = rustc_for_cargo_fix ( ) ;
@@ -73,7 +72,7 @@ fn expect_fix_runs_rustc_n_times(
73
72
execs
74
73
. env ( "RUSTC" , & rustc)
75
74
. env ( "RUSTC_FIX_SHIM_SEQUENCE" , sequence_str)
76
- . with_stderr ( expected_stderr) ;
75
+ . with_stderr_data ( expected_stderr) ;
77
76
extra_execs ( & mut execs) ;
78
77
execs. run ( ) ;
79
78
let lib_rs = p. read_file ( "src/lib.rs" ) ;
@@ -270,10 +269,11 @@ fn fix_no_suggestions() {
270
269
expect_fix_runs_rustc_n_times (
271
270
& [ Step :: SuccessNoOutput ] ,
272
271
|_execs| { } ,
273
- "\
274
- [CHECKING] foo [..]
275
- [FINISHED] [..]
276
- " ,
272
+ str![ [ r#"
273
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
274
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
275
+
276
+ "# ] ] ,
277
277
"// fix-count 0" ,
278
278
) ;
279
279
}
@@ -284,11 +284,12 @@ fn fix_one_suggestion() {
284
284
expect_fix_runs_rustc_n_times (
285
285
& [ Step :: OneFix , Step :: SuccessNoOutput ] ,
286
286
|_execs| { } ,
287
- " \
288
- [CHECKING] foo [..]
287
+ str! [ [ r#"
288
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
289
289
[FIXED] src/lib.rs (1 fix)
290
- [FINISHED] [..]
291
- " ,
290
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
291
+
292
+ "# ] ] ,
292
293
"// fix-count 1" ,
293
294
) ;
294
295
}
@@ -299,11 +300,12 @@ fn fix_one_overlapping() {
299
300
expect_fix_runs_rustc_n_times (
300
301
& [ Step :: TwoFixOverlapping , Step :: SuccessNoOutput ] ,
301
302
|_execs| { } ,
302
- " \
303
- [CHECKING] foo [..]
303
+ str! [ [ r#"
304
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
304
305
[FIXED] src/lib.rs (1 fix)
305
- [FINISHED] [..]
306
- " ,
306
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
307
+
308
+ "# ] ] ,
307
309
"// fix-count 2" ,
308
310
) ;
309
311
}
@@ -321,9 +323,9 @@ fn fix_overlapping_max() {
321
323
Step :: TwoFixOverlapping ,
322
324
] ,
323
325
|_execs| { } ,
324
- " \
325
- [CHECKING] foo [..]
326
- warning: error applying suggestions to `src/lib.rs`
326
+ str! [ [ r#"
327
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
328
+ [WARNING] error applying suggestions to `src/lib.rs`
327
329
328
330
The full error message was:
329
331
@@ -341,9 +343,10 @@ fixing code with the `--broken-code` flag
341
343
[FIXED] src/lib.rs (4 fixes)
342
344
rustc fix shim comment 5
343
345
rustc fix shim comment 6
344
- warning: `foo` (lib) generated 2 warnings (run `cargo fix --lib -p foo` to apply 2 suggestions)
345
- [FINISHED] [..]
346
- " ,
346
+ [WARNING] `foo` (lib) generated 2 warnings (run `cargo fix --lib -p foo` to apply 2 suggestions)
347
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
348
+
349
+ "# ] ] ,
347
350
"// fix-count 5" ,
348
351
) ;
349
352
}
@@ -355,9 +358,9 @@ fn fix_verification_failed() {
355
358
expect_fix_runs_rustc_n_times (
356
359
& [ Step :: OneFix , Step :: Error ] ,
357
360
|_execs| { } ,
358
- " \
359
- [CHECKING] foo [..]
360
- warning: failed to automatically apply fixes suggested by rustc to crate `foo`
361
+ str! [ [ r#"
362
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
363
+ [WARNING] failed to automatically apply fixes suggested by rustc to crate `foo`
361
364
362
365
after fixes were automatically applied the compiler reported errors within these files:
363
366
@@ -377,9 +380,10 @@ rustc fix shim error count=2
377
380
Original diagnostics will follow.
378
381
379
382
rustc fix shim comment 1
380
- warning: `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
381
- [FINISHED] [..]
382
- " ,
383
+ [WARNING] `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
384
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
385
+
386
+ "# ] ] ,
383
387
"// fix-count 0" ,
384
388
) ;
385
389
}
@@ -394,9 +398,9 @@ fn fix_verification_failed_clippy() {
394
398
|execs| {
395
399
execs. env ( "RUSTC_WORKSPACE_WRAPPER" , tools:: wrapped_clippy_driver ( ) ) ;
396
400
} ,
397
- " \
398
- [CHECKING] foo [..]
399
- warning: failed to automatically apply fixes suggested by rustc to crate `foo`
401
+ str! [ [ r#"
402
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
403
+ [WARNING] failed to automatically apply fixes suggested by rustc to crate `foo`
400
404
401
405
after fixes were automatically applied the compiler reported errors within these files:
402
406
@@ -416,9 +420,10 @@ rustc fix shim error count=2
416
420
Original diagnostics will follow.
417
421
418
422
rustc fix shim comment 1
419
- warning: `foo` (lib) generated 1 warning (run `cargo clippy --fix --lib -p foo` to apply 1 suggestion)
420
- [FINISHED] [..]
421
- " ,
423
+ [WARNING] `foo` (lib) generated 1 warning (run `cargo clippy --fix --lib -p foo` to apply 1 suggestion)
424
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
425
+
426
+ "# ] ] ,
422
427
"// fix-count 0" ,
423
428
) ;
424
429
}
@@ -429,12 +434,13 @@ fn warnings() {
429
434
expect_fix_runs_rustc_n_times (
430
435
& [ Step :: Warning ] ,
431
436
|_execs| { } ,
432
- " \
433
- [CHECKING] foo [..]
437
+ str! [ [ r#"
438
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
434
439
rustc fix shim warning count=1
435
- warning: `foo` (lib) generated 1 warning
436
- [FINISHED] [..]
437
- " ,
440
+ [WARNING] `foo` (lib) generated 1 warning
441
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
442
+
443
+ "# ] ] ,
438
444
"// fix-count 0" ,
439
445
) ;
440
446
}
@@ -447,11 +453,12 @@ fn starts_with_error() {
447
453
|execs| {
448
454
execs. with_status ( 101 ) ;
449
455
} ,
450
- " \
451
- [CHECKING] foo [..]
456
+ str! [ [ r#"
457
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
452
458
rustc fix shim error count=1
453
- error: could not compile `foo` (lib) due to 1 previous error
454
- " ,
459
+ [ERROR] could not compile `foo` (lib) due to 1 previous error
460
+
461
+ "# ] ] ,
455
462
"// fix-count 0" ,
456
463
) ;
457
464
}
@@ -464,11 +471,12 @@ fn broken_code_no_suggestions() {
464
471
|execs| {
465
472
execs. arg ( "--broken-code" ) . with_status ( 101 ) ;
466
473
} ,
467
- " \
468
- [CHECKING] foo [..]
474
+ str! [ [ r#"
475
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
469
476
rustc fix shim error count=1
470
- error: could not compile `foo` (lib) due to 1 previous error
471
- " ,
477
+ [ERROR] could not compile `foo` (lib) due to 1 previous error
478
+
479
+ "# ] ] ,
472
480
"// fix-count 0" ,
473
481
) ;
474
482
}
@@ -481,9 +489,9 @@ fn broken_code_one_suggestion() {
481
489
|execs| {
482
490
execs. arg ( "--broken-code" ) . with_status ( 101 ) ;
483
491
} ,
484
- " \
485
- [CHECKING] foo [..]
486
- warning: failed to automatically apply fixes suggested by rustc to crate `foo`
492
+ str! [ [ r#"
493
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
494
+ [WARNING] failed to automatically apply fixes suggested by rustc to crate `foo`
487
495
488
496
after fixes were automatically applied the compiler reported errors within these files:
489
497
@@ -504,9 +512,10 @@ Original diagnostics will follow.
504
512
505
513
rustc fix shim comment 1
506
514
rustc fix shim error count=2
507
- warning: `foo` (lib) generated 1 warning
508
- error: could not compile `foo` (lib) due to 1 previous error; 1 warning emitted
509
- " ,
515
+ [WARNING] `foo` (lib) generated 1 warning
516
+ [ERROR] could not compile `foo` (lib) due to 1 previous error; 1 warning emitted
517
+
518
+ "# ] ] ,
510
519
"// fix-count 1" ,
511
520
) ;
512
521
}
0 commit comments