@@ -14,6 +14,7 @@ use color_eyre::eyre::{eyre, Result};
14
14
use crossbeam_channel:: { unbounded, Receiver , Sender } ;
15
15
use dependencies:: { Build , BuildManager } ;
16
16
use parser:: { ErrorMatch , ErrorMatchKind , OptWithLine , Revisioned , Spanned } ;
17
+ use per_test_config:: TestConfig ;
17
18
use rustc_stderr:: { Level , Message } ;
18
19
use spanned:: Span ;
19
20
use status_emitter:: { StatusEmitter , TestStatus } ;
@@ -411,7 +412,14 @@ fn parse_and_test_file(
411
412
built_deps = true ;
412
413
}
413
414
414
- let result = status. run_test ( build_manager, & config, & comments) ;
415
+ let test_config = TestConfig {
416
+ config : config. clone ( ) ,
417
+ revision,
418
+ comments : & comments,
419
+ path : status. path ( ) ,
420
+ } ;
421
+
422
+ let result = run_test ( build_manager, test_config) ;
415
423
TestRun { result, status }
416
424
} )
417
425
. collect ( ) )
@@ -565,66 +573,62 @@ fn build_aux(
565
573
Ok ( extra_args)
566
574
}
567
575
568
- impl dyn TestStatus {
569
- fn run_test (
570
- & self ,
571
- build_manager : & BuildManager < ' _ > ,
572
- config : & Config ,
573
- comments : & Comments ,
574
- ) -> TestResult {
575
- let path = self . path ( ) ;
576
- let revision = self . revision ( ) ;
577
-
578
- let extra_args = build_aux_files (
579
- & path. parent ( ) . unwrap ( ) . join ( "auxiliary" ) ,
580
- comments,
581
- revision,
582
- config,
583
- build_manager,
584
- ) ?;
585
-
586
- let mut config = config. clone ( ) ;
587
-
588
- // Put aux builds into a separate directory per path so that multiple aux files
589
- // from different directories (but with the same file name) don't collide.
590
- let relative = strip_path_prefix ( path. parent ( ) . unwrap ( ) , & config. out_dir ) ;
591
-
592
- config. out_dir . extend ( relative) ;
593
-
594
- let mut cmd = build_command ( path, & config, revision, comments) ?;
595
- cmd. args ( & extra_args) ;
596
- let stdin = path. with_extension ( if revision. is_empty ( ) {
597
- "stdin" . into ( )
598
- } else {
599
- format ! ( "{revision}.stdin" )
600
- } ) ;
601
- if stdin. exists ( ) {
602
- cmd. stdin ( std:: fs:: File :: open ( stdin) . unwrap ( ) ) ;
603
- }
576
+ fn run_test (
577
+ build_manager : & BuildManager < ' _ > ,
578
+ TestConfig {
579
+ mut config,
580
+ revision,
581
+ comments,
582
+ path,
583
+ } : TestConfig < ' _ > ,
584
+ ) -> TestResult {
585
+ let extra_args = build_aux_files (
586
+ & path. parent ( ) . unwrap ( ) . join ( "auxiliary" ) ,
587
+ comments,
588
+ revision,
589
+ & config,
590
+ build_manager,
591
+ ) ?;
604
592
605
- let ( cmd, output) = run_command ( cmd) ?;
593
+ // Put aux builds into a separate directory per path so that multiple aux files
594
+ // from different directories (but with the same file name) don't collide.
595
+ let relative = strip_path_prefix ( path. parent ( ) . unwrap ( ) , & config. out_dir ) ;
606
596
607
- let mode = comments. mode ( revision) ?;
608
- let ( cmd, output) = check_test_result (
609
- cmd,
610
- match * mode {
611
- Mode :: Run { .. } => Mode :: Pass ,
612
- _ => * mode,
613
- } ,
614
- path,
615
- & config,
616
- revision,
617
- comments,
618
- output,
619
- ) ?;
620
-
621
- if let Mode :: Run { .. } = * mode {
622
- return run_test_binary ( mode, path, revision, comments, cmd, & config) ;
623
- }
597
+ config. out_dir . extend ( relative) ;
624
598
625
- run_rustfix ( output, path, comments, revision, & config, * mode, extra_args) ?;
626
- Ok ( TestOk :: Ok )
599
+ let mut cmd = build_command ( path, & config, revision, comments) ?;
600
+ cmd. args ( & extra_args) ;
601
+ let stdin = path. with_extension ( if revision. is_empty ( ) {
602
+ "stdin" . into ( )
603
+ } else {
604
+ format ! ( "{revision}.stdin" )
605
+ } ) ;
606
+ if stdin. exists ( ) {
607
+ cmd. stdin ( std:: fs:: File :: open ( stdin) . unwrap ( ) ) ;
608
+ }
609
+
610
+ let ( cmd, output) = run_command ( cmd) ?;
611
+
612
+ let mode = comments. mode ( revision) ?;
613
+ let ( cmd, output) = check_test_result (
614
+ cmd,
615
+ match * mode {
616
+ Mode :: Run { .. } => Mode :: Pass ,
617
+ _ => * mode,
618
+ } ,
619
+ path,
620
+ & config,
621
+ revision,
622
+ comments,
623
+ output,
624
+ ) ?;
625
+
626
+ if let Mode :: Run { .. } = * mode {
627
+ return run_test_binary ( mode, path, revision, comments, cmd, & config) ;
627
628
}
629
+
630
+ run_rustfix ( output, path, comments, revision, & config, * mode, extra_args) ?;
631
+ Ok ( TestOk :: Ok )
628
632
}
629
633
630
634
fn run_command ( mut cmd : Command ) -> Result < ( Command , Output ) , Errored > {
0 commit comments