@@ -3,7 +3,6 @@ use regex::bytes::Regex;
3
3
use std:: ffi:: OsString ;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
use std:: { env, process:: Command } ;
6
- use ui_test:: status_emitter:: StatusEmitter ;
7
6
use ui_test:: CommandBuilder ;
8
7
use ui_test:: { color_eyre:: Result , Config , Match , Mode , OutputConflictHandling } ;
9
8
@@ -76,7 +75,7 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
76
75
let skip_ui_checks = env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) ;
77
76
78
77
let output_conflict_handling = match ( env:: var_os ( "MIRI_BLESS" ) . is_some ( ) , skip_ui_checks) {
79
- ( false , false ) => OutputConflictHandling :: Error ,
78
+ ( false , false ) => OutputConflictHandling :: Error ( "./miri bless" . into ( ) ) ,
80
79
( true , false ) => OutputConflictHandling :: Bless ,
81
80
( false , true ) => OutputConflictHandling :: Ignore ,
82
81
( true , true ) => panic ! ( "cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ,
@@ -86,13 +85,11 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
86
85
target : Some ( target. to_owned ( ) ) ,
87
86
stderr_filters : STDERR . clone ( ) ,
88
87
stdout_filters : STDOUT . clone ( ) ,
89
- root_dir : PathBuf :: from ( path) ,
90
88
mode,
91
89
program,
92
90
output_conflict_handling,
93
- quiet : false ,
94
91
edition : Some ( "2021" . into ( ) ) ,
95
- ..Config :: default ( )
92
+ ..Config :: rustc ( path . into ( ) )
96
93
} ;
97
94
98
95
let use_std = env:: var_os ( "MIRI_NO_STD" ) . is_none ( ) ;
@@ -113,39 +110,48 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
113
110
}
114
111
115
112
fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
116
- let mut config = test_config ( target, path, mode, with_dependencies) ;
113
+ let config = test_config ( target, path, mode, with_dependencies) ;
117
114
118
115
// Handle command-line arguments.
119
116
let mut after_dashdash = false ;
120
- config. path_filter . extend ( std:: env:: args ( ) . skip ( 1 ) . filter ( |arg| {
121
- if after_dashdash {
122
- // Just propagate everything.
123
- return true ;
124
- }
125
- match & * * arg {
126
- "--quiet" => {
127
- config. quiet = true ;
128
- false
129
- }
130
- "--" => {
131
- after_dashdash = true ;
132
- false
117
+ let mut quiet = false ;
118
+ let filters = std:: env:: args ( )
119
+ . skip ( 1 )
120
+ . filter ( |arg| {
121
+ if after_dashdash {
122
+ // Just propagate everything.
123
+ return true ;
133
124
}
134
- s if s. starts_with ( '-' ) => {
135
- panic ! ( "unknown compiletest flag `{s}`" ) ;
125
+ match & * * arg {
126
+ "--quiet" => {
127
+ quiet = true ;
128
+ false
129
+ }
130
+ "--" => {
131
+ after_dashdash = true ;
132
+ false
133
+ }
134
+ s if s. starts_with ( '-' ) => {
135
+ panic ! ( "unknown compiletest flag `{s}`" ) ;
136
+ }
137
+ _ => true ,
136
138
}
137
- _ => true ,
138
- }
139
- } ) ) ;
140
-
139
+ } )
140
+ . collect :: < Vec < _ > > ( ) ;
141
141
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
142
142
ui_test:: run_tests_generic (
143
143
config,
144
144
// The files we're actually interested in (all `.rs` files).
145
- |path| path. extension ( ) . is_some_and ( |ext| ext == "rs" ) ,
145
+ |path| {
146
+ path. extension ( ) . is_some_and ( |ext| ext == "rs" )
147
+ && ( filters. is_empty ( ) || filters. iter ( ) . any ( |f| path. starts_with ( f) ) )
148
+ } ,
146
149
// This could be used to overwrite the `Config` on a per-test basis.
147
150
|_, _| None ,
148
- TextAndGha ,
151
+ (
152
+ ui_test:: status_emitter:: Text ,
153
+ ui_test:: status_emitter:: Gha :: < false > { name : format ! ( "{mode:?} {path} ({target})" ) } ,
154
+ ) ,
149
155
)
150
156
}
151
157
@@ -270,45 +276,3 @@ fn run_dep_mode(target: String, mut args: impl Iterator<Item = OsString>) -> Res
270
276
cmd. args ( args) ;
271
277
if cmd. spawn ( ) ?. wait ( ) ?. success ( ) { Ok ( ( ) ) } else { std:: process:: exit ( 1 ) }
272
278
}
273
-
274
- /// This is a custom renderer for `ui_test` output that does not emit github actions
275
- /// `group`s, while still producing regular github actions messages on test failures.
276
- struct TextAndGha ;
277
- impl StatusEmitter for TextAndGha {
278
- fn failed_test < ' a > (
279
- & ' a self ,
280
- revision : & ' a str ,
281
- path : & ' a Path ,
282
- cmd : & ' a Command ,
283
- stderr : & ' a [ u8 ] ,
284
- ) -> Box < dyn std:: fmt:: Debug + ' a > {
285
- Box :: new ( (
286
- ui_test:: status_emitter:: Gha :: < false > . failed_test ( revision, path, cmd, stderr) ,
287
- ui_test:: status_emitter:: Text . failed_test ( revision, path, cmd, stderr) ,
288
- ) )
289
- }
290
-
291
- fn run_tests ( & self , _config : & Config ) -> Box < dyn ui_test:: status_emitter:: DuringTestRun > {
292
- Box :: new ( TextAndGha )
293
- }
294
-
295
- fn finalize (
296
- & self ,
297
- failures : usize ,
298
- succeeded : usize ,
299
- ignored : usize ,
300
- filtered : usize ,
301
- ) -> Box < dyn ui_test:: status_emitter:: Summary > {
302
- Box :: new ( (
303
- ui_test:: status_emitter:: Gha :: < false > . finalize ( failures, succeeded, ignored, filtered) ,
304
- ui_test:: status_emitter:: Text . finalize ( failures, succeeded, ignored, filtered) ,
305
- ) )
306
- }
307
- }
308
-
309
- impl ui_test:: status_emitter:: DuringTestRun for TextAndGha {
310
- fn test_result ( & mut self , path : & Path , revision : & str , result : & ui_test:: TestResult ) {
311
- ui_test:: status_emitter:: Text . test_result ( path, revision, result) ;
312
- ui_test:: status_emitter:: Gha :: < false > . test_result ( path, revision, result) ;
313
- }
314
- }
0 commit comments