@@ -82,9 +82,16 @@ fn build_native_lib() -> PathBuf {
8282 native_lib_path
8383}
8484
85+ struct WithDependencies { }
86+
8587/// Does *not* set any args or env vars, since it is shared between the test runner and
8688/// run_dep_mode.
87- fn miri_config ( target : & str , path : & str , mode : Mode , with_dependencies : bool ) -> Config {
89+ fn miri_config (
90+ target : & str ,
91+ path : & str ,
92+ mode : Mode ,
93+ with_dependencies : Option < WithDependencies > ,
94+ ) -> Config {
8895 // Miri is rustc-like, so we create a default builder for rustc and modify it
8996 let mut program = CommandBuilder :: rustc ( ) ;
9097 program. program = miri_path ( ) ;
@@ -119,7 +126,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
119126 // keep in sync with `./miri run`
120127 config. comment_defaults . base ( ) . add_custom ( "edition" , Edition ( "2021" . into ( ) ) ) ;
121128
122- if with_dependencies {
129+ if let Some ( WithDependencies { } ) = with_dependencies {
123130 config. comment_defaults . base ( ) . set_custom ( "dependencies" , DependencyBuilder {
124131 program : CommandBuilder {
125132 // Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
@@ -146,7 +153,20 @@ fn run_tests(
146153 with_dependencies : bool ,
147154 tmpdir : & Path ,
148155) -> Result < ( ) > {
156+ // Handle command-line arguments.
157+ let mut args = ui_test:: Args :: test ( ) ?;
158+ args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
159+
160+ let with_dependencies = with_dependencies. then_some ( WithDependencies { } ) ;
161+
149162 let mut config = miri_config ( target, path, mode, with_dependencies) ;
163+ config. with_args ( & args) ;
164+ config. bless_command = Some ( "./miri test --bless" . into ( ) ) ;
165+
166+ if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
167+ assert ! ( !args. bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
168+ config. output_conflict_handling = OutputConflictHandling :: Ignore ;
169+ }
150170
151171 // Add a test env var to do environment communication tests.
152172 config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
@@ -182,16 +202,6 @@ fn run_tests(
182202 config. program . args . push ( flag) ;
183203 }
184204
185- // Handle command-line arguments.
186- let mut args = ui_test:: Args :: test ( ) ?;
187- args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
188- config. with_args ( & args) ;
189- config. bless_command = Some ( "./miri test --bless" . into ( ) ) ;
190-
191- if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
192- assert ! ( !args. bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
193- config. output_conflict_handling = OutputConflictHandling :: Ignore ;
194- }
195205 eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
196206 ui_test:: run_tests_generic (
197207 // Only run one test suite. In the future we can add all test suites to one `Vec` and run
@@ -327,7 +337,7 @@ fn main() -> Result<()> {
327337}
328338
329339fn run_dep_mode ( target : String , args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
330- let mut config = miri_config ( & target, "" , Mode :: RunDep , /* with dependencies */ true ) ;
340+ let mut config = miri_config ( & target, "" , Mode :: RunDep , Some ( WithDependencies { } ) ) ;
331341 config. comment_defaults . base ( ) . custom . remove ( "edition" ) ; // `./miri` adds an `--edition` in `args`, so don't set it twice
332342 config. fill_host_and_target ( ) ?;
333343 config. program . args = args. collect ( ) ;
0 commit comments