@@ -2,6 +2,8 @@ use colored::*;
22use regex:: bytes:: Regex ;
33use std:: path:: { Path , PathBuf } ;
44use std:: { env, process:: Command } ;
5+ use ui_test:: status_emitter:: StatusEmitter ;
6+ use ui_test:: CommandBuilder ;
57use ui_test:: { color_eyre:: Result , Config , Match , Mode , OutputConflictHandling } ;
68
79fn miri_path ( ) -> PathBuf {
@@ -50,33 +52,35 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
5052 stdout_filters : STDOUT . clone ( ) ,
5153 root_dir : PathBuf :: from ( path) ,
5254 mode,
53- program : miri_path ( ) ,
55+ program : CommandBuilder :: rustc ( ) ,
5456 quiet : false ,
5557 edition : Some ( "2021" . into ( ) ) ,
5658 ..Config :: default ( )
5759 } ;
5860
61+ config. program . program = miri_path ( ) ;
62+
5963 let in_rustc_test_suite = option_env ! ( "RUSTC_STAGE" ) . is_some ( ) ;
6064
6165 // Add some flags we always want.
6266 if in_rustc_test_suite {
6367 // Less aggressive warnings to make the rustc toolstate management less painful.
6468 // (We often get warnings when e.g. a feature gets stabilized or some lint gets added/improved.)
65- config. args . push ( "-Astable-features" . into ( ) ) ;
66- config. args . push ( "-Aunused" . into ( ) ) ;
69+ config. program . args . push ( "-Astable-features" . into ( ) ) ;
70+ config. program . args . push ( "-Aunused" . into ( ) ) ;
6771 } else {
68- config. args . push ( "-Dwarnings" . into ( ) ) ;
69- config. args . push ( "-Dunused" . into ( ) ) ;
72+ config. program . args . push ( "-Dwarnings" . into ( ) ) ;
73+ config. program . args . push ( "-Dunused" . into ( ) ) ;
7074 }
7175 if let Ok ( extra_flags) = env:: var ( "MIRIFLAGS" ) {
7276 for flag in extra_flags. split_whitespace ( ) {
73- config. args . push ( flag. into ( ) ) ;
77+ config. program . args . push ( flag. into ( ) ) ;
7478 }
7579 }
76- config. args . push ( "-Zui-testing" . into ( ) ) ;
80+ config. program . args . push ( "-Zui-testing" . into ( ) ) ;
7781 if let Some ( target) = & config. target {
78- config. args . push ( "--target" . into ( ) ) ;
79- config. args . push ( target. into ( ) ) ;
82+ config. program . args . push ( "--target" . into ( ) ) ;
83+ config. program . args . push ( target. into ( ) ) ;
8084 }
8185
8286 // If we're on linux, and we're testing the extern-so functionality,
@@ -86,7 +90,7 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
8690 let so_file_path = build_so_for_c_ffi_tests ( ) ;
8791 let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
8892 flag. push ( so_file_path. into_os_string ( ) ) ;
89- config. args . push ( flag) ;
93+ config. program . args . push ( flag) ;
9094 }
9195
9296 let skip_ui_checks = env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) ;
@@ -135,7 +139,12 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
135139 "run" . into( ) , // There is no `cargo miri build` so we just use `cargo miri run`.
136140 ] ;
137141 }
138- ui_test:: run_tests ( config)
142+ ui_test:: run_tests_generic (
143+ config,
144+ |path| path. extension ( ) . is_some_and ( |ext| ext == "rs" ) ,
145+ |_, _| None ,
146+ TextAndGha ,
147+ )
139148}
140149
141150macro_rules! regexes {
@@ -235,3 +244,45 @@ fn main() -> Result<()> {
235244
236245 Ok ( ( ) )
237246}
247+
248+ /// This is a custom renderer for `ui_test` output that does not emit github actions
249+ /// `group`s, while still producing regular github actions messages on test failures.
250+ struct TextAndGha ;
251+ impl StatusEmitter for TextAndGha {
252+ fn failed_test < ' a > (
253+ & ' a self ,
254+ revision : & ' a str ,
255+ path : & ' a Path ,
256+ cmd : & ' a Command ,
257+ stderr : & ' a [ u8 ] ,
258+ ) -> Box < dyn std:: fmt:: Debug + ' a > {
259+ Box :: new ( (
260+ ui_test:: status_emitter:: Gha :: < false > . failed_test ( revision, path, cmd, stderr) ,
261+ ui_test:: status_emitter:: Text . failed_test ( revision, path, cmd, stderr) ,
262+ ) )
263+ }
264+
265+ fn run_tests ( & self , _config : & Config ) -> Box < dyn ui_test:: status_emitter:: DuringTestRun > {
266+ Box :: new ( TextAndGha )
267+ }
268+
269+ fn finalize (
270+ & self ,
271+ failures : usize ,
272+ succeeded : usize ,
273+ ignored : usize ,
274+ filtered : usize ,
275+ ) -> Box < dyn ui_test:: status_emitter:: Summary > {
276+ Box :: new ( (
277+ ui_test:: status_emitter:: Gha :: < false > . finalize ( failures, succeeded, ignored, filtered) ,
278+ ui_test:: status_emitter:: Text . finalize ( failures, succeeded, ignored, filtered) ,
279+ ) )
280+ }
281+ }
282+
283+ impl ui_test:: status_emitter:: DuringTestRun for TextAndGha {
284+ fn test_result ( & mut self , path : & Path , revision : & str , result : & ui_test:: TestResult ) {
285+ ui_test:: status_emitter:: Text . test_result ( path, revision, result) ;
286+ ui_test:: status_emitter:: Gha :: < false > . test_result ( path, revision, result) ;
287+ }
288+ }
0 commit comments