@@ -5,7 +5,7 @@ use std::num::NonZeroUsize;
55use std:: path:: { Path , PathBuf } ;
66use std:: { env, process:: Command } ;
77use ui_test:: { color_eyre:: Result , Config , Match , Mode , OutputConflictHandling } ;
8- use ui_test:: { status_emitter, CommandBuilder } ;
8+ use ui_test:: { status_emitter, CommandBuilder , Format , RustfixMode } ;
99
1010fn miri_path ( ) -> PathBuf {
1111 PathBuf :: from ( option_env ! ( "MIRI" ) . unwrap_or ( env ! ( "CARGO_BIN_EXE_miri" ) ) )
@@ -79,25 +79,17 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
7979 program. args . push ( flag) ;
8080 }
8181
82- let bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
83- let skip_ui_checks = env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) ;
84-
85- let output_conflict_handling = match ( bless, skip_ui_checks) {
86- ( false , false ) => OutputConflictHandling :: Error ( "./miri test --bless" . into ( ) ) ,
87- ( true , false ) => OutputConflictHandling :: Bless ,
88- ( false , true ) => OutputConflictHandling :: Ignore ,
89- ( true , true ) => panic ! ( "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ,
90- } ;
91-
9282 let mut config = Config {
9383 target : Some ( target. to_owned ( ) ) ,
9484 stderr_filters : STDERR . clone ( ) ,
9585 stdout_filters : STDOUT . clone ( ) ,
9686 mode,
9787 program,
98- output_conflict_handling,
9988 out_dir : PathBuf :: from ( std:: env:: var_os ( "CARGO_TARGET_DIR" ) . unwrap ( ) ) . join ( "ui" ) ,
10089 edition : Some ( "2021" . into ( ) ) ,
90+ threads : std:: env:: var ( "MIRI_TEST_THREADS" )
91+ . ok ( )
92+ . map ( |threads| NonZeroUsize :: new ( threads. parse ( ) . unwrap ( ) ) . unwrap ( ) ) ,
10193 ..Config :: rustc ( path)
10294 } ;
10395
@@ -121,25 +113,31 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
121113}
122114
123115fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
124- let config = test_config ( target, path, mode, with_dependencies) ;
116+ let mut config = test_config ( target, path, mode, with_dependencies) ;
125117
126118 // Handle command-line arguments.
127- let args = ui_test:: Args :: test ( ) ;
128- let quiet = args. quiet ;
119+ let args = ui_test:: Args :: test ( ) ?;
120+ let default_bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
121+ config. with_args ( & args, default_bless) ;
122+ if let OutputConflictHandling :: Error ( msg) = & mut config. output_conflict_handling {
123+ * msg = "./miri test --bless" . into ( ) ;
124+ }
125+ if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
126+ assert ! ( !default_bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
127+ config. output_conflict_handling = OutputConflictHandling :: Ignore ;
128+ }
129129 eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
130130 ui_test:: run_tests_generic (
131131 vec ! [ config] ,
132- std:: env:: var ( "MIRI_TEST_THREADS" ) . map_or_else (
133- |_| std:: thread:: available_parallelism ( ) . unwrap ( ) ,
134- |threads| NonZeroUsize :: new ( threads. parse ( ) . unwrap ( ) ) . unwrap ( ) ,
135- ) ,
136- args,
137132 // The files we're actually interested in (all `.rs` files).
138133 ui_test:: default_file_filter,
139134 // This could be used to overwrite the `Config` on a per-test basis.
140135 |_, _, _| { } ,
141136 (
142- if quiet { status_emitter:: Text :: quiet ( ) } else { status_emitter:: Text :: verbose ( ) } ,
137+ match args. format {
138+ Format :: Terse => status_emitter:: Text :: quiet ( ) ,
139+ Format :: Pretty => status_emitter:: Text :: verbose ( ) ,
140+ } ,
143141 status_emitter:: Gha :: < /* GHA Actions groups*/ false > {
144142 name : format ! ( "{mode:?} {path} ({target})" ) ,
145143 } ,
@@ -244,21 +242,21 @@ fn main() -> Result<()> {
244242 ui ( Mode :: Pass , "tests/pass-dep" , & target, WithDependencies ) ?;
245243 ui ( Mode :: Panic , "tests/panic" , & target, WithDependencies ) ?;
246244 ui (
247- Mode :: Fail { require_patterns : true , rustfix : false } ,
245+ Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
248246 "tests/fail" ,
249247 & target,
250248 WithoutDependencies ,
251249 ) ?;
252250 ui (
253- Mode :: Fail { require_patterns : true , rustfix : false } ,
251+ Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
254252 "tests/fail-dep" ,
255253 & target,
256254 WithDependencies ,
257255 ) ?;
258256 if cfg ! ( target_os = "linux" ) {
259257 ui ( Mode :: Pass , "tests/extern-so/pass" , & target, WithoutDependencies ) ?;
260258 ui (
261- Mode :: Fail { require_patterns : true , rustfix : false } ,
259+ Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
262260 "tests/extern-so/fail" ,
263261 & target,
264262 WithoutDependencies ,
@@ -270,8 +268,12 @@ fn main() -> Result<()> {
270268
271269fn run_dep_mode ( target : String , mut args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
272270 let path = args. next ( ) . expect ( "./miri run-dep must be followed by a file name" ) ;
273- let mut config =
274- test_config ( & target, "" , Mode :: Yolo { rustfix : false } , /* with dependencies */ true ) ;
271+ let mut config = test_config (
272+ & target,
273+ "" ,
274+ Mode :: Yolo { rustfix : RustfixMode :: Disabled } ,
275+ /* with dependencies */ true ,
276+ ) ;
275277 config. program . args . clear ( ) ; // We want to give the user full control over flags
276278 let dep_args = config. build_dependencies ( ) ?;
277279
0 commit comments