11use colored:: * ;
22use regex:: bytes:: Regex ;
3+ use std:: io:: Write ;
34use std:: path:: { Path , PathBuf } ;
45use std:: { env, process:: Command } ;
56use ui_test:: status_emitter:: StatusEmitter ;
@@ -45,7 +46,13 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
4546 so_file_path
4647}
4748
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 {
4956 // Miri is rustc-like, so we create a default builder for rustc and modify it
5057 let mut program = CommandBuilder :: rustc ( ) ;
5158 program. program = miri_path ( ) ;
@@ -105,7 +112,7 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
105112
106113 // Handle command-line arguments.
107114 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| {
109116 if after_dashdash {
110117 // Just propagate everything.
111118 return true ;
@@ -140,6 +147,11 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
140147 "run" . into( ) , // There is no `cargo miri build` so we just use `cargo miri run`.
141148 ] ;
142149 }
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) ;
143155
144156 eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
145157 ui_test:: run_tests_generic (
@@ -226,8 +238,15 @@ fn get_target() -> String {
226238
227239fn main ( ) -> Result < ( ) > {
228240 ui_test:: color_eyre:: install ( ) ?;
241+
229242 let target = get_target ( ) ;
230243
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+
231250 // Add a test env var to do environment communication tests.
232251 env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
233252 // 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<()> {
250269 Ok ( ( ) )
251270}
252271
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+
253287/// This is a custom renderer for `ui_test` output that does not emit github actions
254288/// `group`s, while still producing regular github actions messages on test failures.
255289struct TextAndGha ;
0 commit comments