1
1
use colored:: * ;
2
2
use regex:: bytes:: Regex ;
3
+ use std:: io:: Write ;
3
4
use std:: path:: { Path , PathBuf } ;
4
5
use std:: { env, process:: Command } ;
5
6
use ui_test:: status_emitter:: StatusEmitter ;
@@ -45,7 +46,13 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
45
46
so_file_path
46
47
}
47
48
48
- fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
49
+ fn run_test_config (
50
+ args : impl Iterator < Item = String > ,
51
+ target : & str ,
52
+ path : & str ,
53
+ mode : Mode ,
54
+ with_dependencies : bool ,
55
+ ) -> Config {
49
56
// Miri is rustc-like, so we create a default builder for rustc and modify it
50
57
let mut program = CommandBuilder :: rustc ( ) ;
51
58
program. program = miri_path ( ) ;
@@ -105,7 +112,7 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
105
112
106
113
// Handle command-line arguments.
107
114
let mut after_dashdash = false ;
108
- config. path_filter . extend ( std :: env :: args ( ) . skip ( 1 ) . filter ( |arg| {
115
+ config. path_filter . extend ( args. filter ( |arg| {
109
116
if after_dashdash {
110
117
// Just propagate everything.
111
118
return true ;
@@ -140,6 +147,11 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
140
147
"run" . into( ) , // There is no `cargo miri build` so we just use `cargo miri run`.
141
148
] ;
142
149
}
150
+ config
151
+ }
152
+
153
+ fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
154
+ let config = run_test_config ( std:: env:: args ( ) . skip ( 1 ) , target, path, mode, with_dependencies) ;
143
155
144
156
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
145
157
ui_test:: run_tests_generic (
@@ -226,8 +238,15 @@ fn get_target() -> String {
226
238
227
239
fn main ( ) -> Result < ( ) > {
228
240
ui_test:: color_eyre:: install ( ) ?;
241
+
229
242
let target = get_target ( ) ;
230
243
244
+ if let Some ( first) = std:: env:: args ( ) . nth ( 1 ) {
245
+ if first == "miri-run-dep-mode" {
246
+ return run_dep_mode ( target) ;
247
+ }
248
+ }
249
+
231
250
// Add a test env var to do environment communication tests.
232
251
env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
233
252
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
@@ -250,6 +269,21 @@ fn main() -> Result<()> {
250
269
Ok ( ( ) )
251
270
}
252
271
272
+ fn run_dep_mode ( target : String ) -> Result < ( ) > {
273
+ let files = std:: env:: args ( ) . skip_while ( |arg| arg != "--" ) . skip ( 1 ) ;
274
+ for path in files {
275
+ let mut config = run_test_config ( std:: iter:: empty ( ) , & target, & path, Mode :: Yolo , true ) ;
276
+ config. program . args . remove ( 0 ) ; // remove the `--error-format=json` argument
277
+ config. program . args . push ( "--color" . into ( ) ) ;
278
+ config. program . args . push ( "always" . into ( ) ) ;
279
+ let output = ui_test:: run_file ( config, Path :: new ( & path) ) ?;
280
+ std:: io:: stderr ( ) . write_all ( & output. stderr ) ?;
281
+ std:: io:: stdout ( ) . write_all ( & output. stdout ) ?;
282
+ std:: process:: exit ( output. status . code ( ) . unwrap ( ) ) ;
283
+ }
284
+ Ok ( ( ) )
285
+ }
286
+
253
287
/// This is a custom renderer for `ui_test` output that does not emit github actions
254
288
/// `group`s, while still producing regular github actions messages on test failures.
255
289
struct TextAndGha ;
0 commit comments