@@ -46,42 +46,30 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
4646}
4747
4848fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
49- let mut config = Config {
50- target : Some ( target. to_owned ( ) ) ,
51- stderr_filters : STDERR . clone ( ) ,
52- stdout_filters : STDOUT . clone ( ) ,
53- root_dir : PathBuf :: from ( path) ,
54- mode,
55- program : CommandBuilder :: rustc ( ) ,
56- quiet : false ,
57- edition : Some ( "2021" . into ( ) ) ,
58- ..Config :: default ( )
59- } ;
60-
61- config. program . program = miri_path ( ) ;
49+ // Miri is rustc-like, so we create a default builder for rustc and modify it
50+ let mut program = CommandBuilder :: rustc ( ) ;
51+ program. program = miri_path ( ) ;
6252
6353 let in_rustc_test_suite = option_env ! ( "RUSTC_STAGE" ) . is_some ( ) ;
6454
6555 // Add some flags we always want.
6656 if in_rustc_test_suite {
6757 // Less aggressive warnings to make the rustc toolstate management less painful.
6858 // (We often get warnings when e.g. a feature gets stabilized or some lint gets added/improved.)
69- config . program . args . push ( "-Astable-features" . into ( ) ) ;
70- config . program . args . push ( "-Aunused" . into ( ) ) ;
59+ program. args . push ( "-Astable-features" . into ( ) ) ;
60+ program. args . push ( "-Aunused" . into ( ) ) ;
7161 } else {
72- config . program . args . push ( "-Dwarnings" . into ( ) ) ;
73- config . program . args . push ( "-Dunused" . into ( ) ) ;
62+ program. args . push ( "-Dwarnings" . into ( ) ) ;
63+ program. args . push ( "-Dunused" . into ( ) ) ;
7464 }
7565 if let Ok ( extra_flags) = env:: var ( "MIRIFLAGS" ) {
7666 for flag in extra_flags. split_whitespace ( ) {
77- config . program . args . push ( flag. into ( ) ) ;
67+ program. args . push ( flag. into ( ) ) ;
7868 }
7969 }
80- config. program . args . push ( "-Zui-testing" . into ( ) ) ;
81- if let Some ( target) = & config. target {
82- config. program . args . push ( "--target" . into ( ) ) ;
83- config. program . args . push ( target. into ( ) ) ;
84- }
70+ program. args . push ( "-Zui-testing" . into ( ) ) ;
71+ program. args . push ( "--target" . into ( ) ) ;
72+ program. args . push ( target. into ( ) ) ;
8573
8674 // If we're on linux, and we're testing the extern-so functionality,
8775 // then build the shared object file for testing external C function calls
@@ -90,18 +78,31 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
9078 let so_file_path = build_so_for_c_ffi_tests ( ) ;
9179 let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
9280 flag. push ( so_file_path. into_os_string ( ) ) ;
93- config . program . args . push ( flag) ;
81+ program. args . push ( flag) ;
9482 }
9583
9684 let skip_ui_checks = env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) ;
9785
98- config . output_conflict_handling = match ( env:: var_os ( "MIRI_BLESS" ) . is_some ( ) , skip_ui_checks) {
86+ let output_conflict_handling = match ( env:: var_os ( "MIRI_BLESS" ) . is_some ( ) , skip_ui_checks) {
9987 ( false , false ) => OutputConflictHandling :: Error ,
10088 ( true , false ) => OutputConflictHandling :: Bless ,
10189 ( false , true ) => OutputConflictHandling :: Ignore ,
10290 ( true , true ) => panic ! ( "cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ,
10391 } ;
10492
93+ let mut config = Config {
94+ target : Some ( target. to_owned ( ) ) ,
95+ stderr_filters : STDERR . clone ( ) ,
96+ stdout_filters : STDOUT . clone ( ) ,
97+ root_dir : PathBuf :: from ( path) ,
98+ mode,
99+ program,
100+ output_conflict_handling,
101+ quiet : false ,
102+ edition : Some ( "2021" . into ( ) ) ,
103+ ..Config :: default ( )
104+ } ;
105+
105106 // Handle command-line arguments.
106107 let mut after_dashdash = false ;
107108 config. path_filter . extend ( std:: env:: args ( ) . skip ( 1 ) . filter ( |arg| {
0 commit comments