@@ -5,7 +5,7 @@ use std::num::NonZeroUsize;
5
5
use std:: path:: { Path , PathBuf } ;
6
6
use std:: { env, process:: Command } ;
7
7
use 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 } ;
9
9
10
10
fn miri_path ( ) -> PathBuf {
11
11
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) ->
79
79
program. args . push ( flag) ;
80
80
}
81
81
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
-
92
82
let mut config = Config {
93
83
target : Some ( target. to_owned ( ) ) ,
94
84
stderr_filters : STDERR . clone ( ) ,
95
85
stdout_filters : STDOUT . clone ( ) ,
96
86
mode,
97
87
program,
98
- output_conflict_handling,
99
88
out_dir : PathBuf :: from ( std:: env:: var_os ( "CARGO_TARGET_DIR" ) . unwrap ( ) ) . join ( "ui" ) ,
100
89
edition : Some ( "2021" . into ( ) ) ,
90
+ threads : std:: env:: var ( "MIRI_TEST_THREADS" )
91
+ . ok ( )
92
+ . map ( |threads| NonZeroUsize :: new ( threads. parse ( ) . unwrap ( ) ) . unwrap ( ) ) ,
101
93
..Config :: rustc ( path)
102
94
} ;
103
95
@@ -121,25 +113,31 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
121
113
}
122
114
123
115
fn 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) ;
125
117
126
118
// 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
+ }
129
129
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
130
130
ui_test:: run_tests_generic (
131
131
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,
137
132
// The files we're actually interested in (all `.rs` files).
138
133
ui_test:: default_file_filter,
139
134
// This could be used to overwrite the `Config` on a per-test basis.
140
135
|_, _, _| { } ,
141
136
(
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
+ } ,
143
141
status_emitter:: Gha :: < /* GHA Actions groups*/ false > {
144
142
name : format ! ( "{mode:?} {path} ({target})" ) ,
145
143
} ,
@@ -244,21 +242,21 @@ fn main() -> Result<()> {
244
242
ui ( Mode :: Pass , "tests/pass-dep" , & target, WithDependencies ) ?;
245
243
ui ( Mode :: Panic , "tests/panic" , & target, WithDependencies ) ?;
246
244
ui (
247
- Mode :: Fail { require_patterns : true , rustfix : false } ,
245
+ Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
248
246
"tests/fail" ,
249
247
& target,
250
248
WithoutDependencies ,
251
249
) ?;
252
250
ui (
253
- Mode :: Fail { require_patterns : true , rustfix : false } ,
251
+ Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
254
252
"tests/fail-dep" ,
255
253
& target,
256
254
WithDependencies ,
257
255
) ?;
258
256
if cfg ! ( target_os = "linux" ) {
259
257
ui ( Mode :: Pass , "tests/extern-so/pass" , & target, WithoutDependencies ) ?;
260
258
ui (
261
- Mode :: Fail { require_patterns : true , rustfix : false } ,
259
+ Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
262
260
"tests/extern-so/fail" ,
263
261
& target,
264
262
WithoutDependencies ,
@@ -270,8 +268,12 @@ fn main() -> Result<()> {
270
268
271
269
fn run_dep_mode ( target : String , mut args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
272
270
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
+ ) ;
275
277
config. program . args . clear ( ) ; // We want to give the user full control over flags
276
278
let dep_args = config. build_dependencies ( ) ?;
277
279
0 commit comments