@@ -13,7 +13,7 @@ use ui_test::custom_flags::edition::Edition;
1313use ui_test:: dependencies:: DependencyBuilder ;
1414use ui_test:: per_test_config:: TestConfig ;
1515use ui_test:: spanned:: Spanned ;
16- use ui_test:: { CommandBuilder , Config , Format , Match , OutputConflictHandling , status_emitter} ;
16+ use ui_test:: { CommandBuilder , Config , Format , Match , ignore_output_conflict , status_emitter} ;
1717
1818#[ derive( Copy , Clone , Debug ) ]
1919enum Mode {
@@ -82,9 +82,18 @@ fn build_native_lib() -> PathBuf {
8282 native_lib_path
8383}
8484
85+ struct WithDependencies {
86+ bless : bool ,
87+ }
88+
8589/// Does *not* set any args or env vars, since it is shared between the test runner and
8690/// run_dep_mode.
87- fn miri_config ( target : & str , path : & str , mode : Mode , with_dependencies : bool ) -> Config {
91+ fn miri_config (
92+ target : & str ,
93+ path : & str ,
94+ mode : Mode ,
95+ with_dependencies : Option < WithDependencies > ,
96+ ) -> Config {
8897 // Miri is rustc-like, so we create a default builder for rustc and modify it
8998 let mut program = CommandBuilder :: rustc ( ) ;
9099 program. program = miri_path ( ) ;
@@ -119,7 +128,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
119128 // keep in sync with `./miri run`
120129 config. comment_defaults . base ( ) . add_custom ( "edition" , Edition ( "2021" . into ( ) ) ) ;
121130
122- if with_dependencies {
131+ if let Some ( WithDependencies { bless } ) = with_dependencies {
123132 config. comment_defaults . base ( ) . set_custom ( "dependencies" , DependencyBuilder {
124133 program : CommandBuilder {
125134 // Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
@@ -134,6 +143,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
134143 } ,
135144 crate_manifest_path : Path :: new ( "test_dependencies" ) . join ( "Cargo.toml" ) ,
136145 build_std : None ,
146+ bless_lockfile : bless,
137147 } ) ;
138148 }
139149 config
@@ -146,7 +156,20 @@ fn run_tests(
146156 with_dependencies : bool ,
147157 tmpdir : & Path ,
148158) -> Result < ( ) > {
159+ // Handle command-line arguments.
160+ let mut args = ui_test:: Args :: test ( ) ?;
161+ args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
162+
163+ let with_dependencies = with_dependencies. then_some ( WithDependencies { bless : args. bless } ) ;
164+
149165 let mut config = miri_config ( target, path, mode, with_dependencies) ;
166+ config. with_args ( & args) ;
167+ config. bless_command = Some ( "./miri test --bless" . into ( ) ) ;
168+
169+ if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
170+ assert ! ( !args. bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
171+ config. output_conflict_handling = ignore_output_conflict;
172+ }
150173
151174 // Add a test env var to do environment communication tests.
152175 config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
@@ -182,16 +205,6 @@ fn run_tests(
182205 config. program . args . push ( flag) ;
183206 }
184207
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- }
195208 eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
196209 ui_test:: run_tests_generic (
197210 // Only run one test suite. In the future we can add all test suites to one `Vec` and run
@@ -327,7 +340,8 @@ fn main() -> Result<()> {
327340}
328341
329342fn run_dep_mode ( target : String , args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
330- let mut config = miri_config ( & target, "" , Mode :: RunDep , /* with dependencies */ true ) ;
343+ let mut config =
344+ miri_config ( & target, "" , Mode :: RunDep , Some ( WithDependencies { bless : false } ) ) ;
331345 config. comment_defaults . base ( ) . custom . remove ( "edition" ) ; // `./miri` adds an `--edition` in `args`, so don't set it twice
332346 config. fill_host_and_target ( ) ?;
333347 config. program . args = args. collect ( ) ;
0 commit comments