1414//! The [`expect_fix_runs_rustc_n_times`] function handles setting everything
1515//! up, and verifying the results.
1616
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 ;
2019use std:: path:: PathBuf ;
2120use std:: sync:: { Mutex , OnceLock } ;
2221
@@ -60,7 +59,7 @@ enum Step {
6059fn expect_fix_runs_rustc_n_times (
6160 sequence : & [ Step ] ,
6261 extra_execs : impl FnOnce ( & mut Execs ) ,
63- expected_stderr : & str ,
62+ expected_stderr : Inline ,
6463 expected_lib_rs : & str ,
6564) {
6665 let rustc = rustc_for_cargo_fix ( ) ;
@@ -73,7 +72,7 @@ fn expect_fix_runs_rustc_n_times(
7372 execs
7473 . env ( "RUSTC" , & rustc)
7574 . env ( "RUSTC_FIX_SHIM_SEQUENCE" , sequence_str)
76- . with_stderr ( expected_stderr) ;
75+ . with_stderr_data ( expected_stderr) ;
7776 extra_execs ( & mut execs) ;
7877 execs. run ( ) ;
7978 let lib_rs = p. read_file ( "src/lib.rs" ) ;
@@ -270,10 +269,11 @@ fn fix_no_suggestions() {
270269 expect_fix_runs_rustc_n_times (
271270 & [ Step :: SuccessNoOutput ] ,
272271 |_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+ "# ] ] ,
277277 "// fix-count 0" ,
278278 ) ;
279279}
@@ -284,11 +284,12 @@ fn fix_one_suggestion() {
284284 expect_fix_runs_rustc_n_times (
285285 & [ Step :: OneFix , Step :: SuccessNoOutput ] ,
286286 |_execs| { } ,
287- " \
288- [CHECKING] foo [..]
287+ str! [ [ r#"
288+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
289289[FIXED] src/lib.rs (1 fix)
290- [FINISHED] [..]
291- " ,
290+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
291+
292+ "# ] ] ,
292293 "// fix-count 1" ,
293294 ) ;
294295}
@@ -299,11 +300,12 @@ fn fix_one_overlapping() {
299300 expect_fix_runs_rustc_n_times (
300301 & [ Step :: TwoFixOverlapping , Step :: SuccessNoOutput ] ,
301302 |_execs| { } ,
302- " \
303- [CHECKING] foo [..]
303+ str! [ [ r#"
304+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
304305[FIXED] src/lib.rs (1 fix)
305- [FINISHED] [..]
306- " ,
306+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
307+
308+ "# ] ] ,
307309 "// fix-count 2" ,
308310 ) ;
309311}
@@ -321,9 +323,9 @@ fn fix_overlapping_max() {
321323 Step :: TwoFixOverlapping ,
322324 ] ,
323325 |_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`
327329
328330The full error message was:
329331
@@ -341,9 +343,10 @@ fixing code with the `--broken-code` flag
341343[FIXED] src/lib.rs (4 fixes)
342344rustc fix shim comment 5
343345rustc 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+ "# ] ] ,
347350 "// fix-count 5" ,
348351 ) ;
349352}
@@ -355,9 +358,9 @@ fn fix_verification_failed() {
355358 expect_fix_runs_rustc_n_times (
356359 & [ Step :: OneFix , Step :: Error ] ,
357360 |_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`
361364
362365after fixes were automatically applied the compiler reported errors within these files:
363366
@@ -377,9 +380,10 @@ rustc fix shim error count=2
377380Original diagnostics will follow.
378381
379382rustc 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+ "# ] ] ,
383387 "// fix-count 0" ,
384388 ) ;
385389}
@@ -394,9 +398,9 @@ fn fix_verification_failed_clippy() {
394398 |execs| {
395399 execs. env ( "RUSTC_WORKSPACE_WRAPPER" , tools:: wrapped_clippy_driver ( ) ) ;
396400 } ,
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`
400404
401405after fixes were automatically applied the compiler reported errors within these files:
402406
@@ -416,9 +420,10 @@ rustc fix shim error count=2
416420Original diagnostics will follow.
417421
418422rustc 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+ "# ] ] ,
422427 "// fix-count 0" ,
423428 ) ;
424429}
@@ -429,12 +434,13 @@ fn warnings() {
429434 expect_fix_runs_rustc_n_times (
430435 & [ Step :: Warning ] ,
431436 |_execs| { } ,
432- " \
433- [CHECKING] foo [..]
437+ str! [ [ r#"
438+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
434439rustc 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+ "# ] ] ,
438444 "// fix-count 0" ,
439445 ) ;
440446}
@@ -447,11 +453,12 @@ fn starts_with_error() {
447453 |execs| {
448454 execs. with_status ( 101 ) ;
449455 } ,
450- " \
451- [CHECKING] foo [..]
456+ str! [ [ r#"
457+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
452458rustc 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+ "# ] ] ,
455462 "// fix-count 0" ,
456463 ) ;
457464}
@@ -464,11 +471,12 @@ fn broken_code_no_suggestions() {
464471 |execs| {
465472 execs. arg ( "--broken-code" ) . with_status ( 101 ) ;
466473 } ,
467- " \
468- [CHECKING] foo [..]
474+ str! [ [ r#"
475+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
469476rustc 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+ "# ] ] ,
472480 "// fix-count 0" ,
473481 ) ;
474482}
@@ -481,9 +489,9 @@ fn broken_code_one_suggestion() {
481489 |execs| {
482490 execs. arg ( "--broken-code" ) . with_status ( 101 ) ;
483491 } ,
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`
487495
488496after fixes were automatically applied the compiler reported errors within these files:
489497
@@ -504,9 +512,10 @@ Original diagnostics will follow.
504512
505513rustc fix shim comment 1
506514rustc 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+ "# ] ] ,
510519 "// fix-count 1" ,
511520 ) ;
512521}
0 commit comments