@@ -81,9 +81,16 @@ fn build_native_lib() -> PathBuf {
81
81
native_lib_path
82
82
}
83
83
84
+ struct WithDependencies { }
85
+
84
86
/// Does *not* set any args or env vars, since it is shared between the test runner and
85
87
/// run_dep_mode.
86
- fn miri_config ( target : & str , path : & str , mode : Mode , with_dependencies : bool ) -> Config {
88
+ fn miri_config (
89
+ target : & str ,
90
+ path : & str ,
91
+ mode : Mode ,
92
+ with_dependencies : Option < WithDependencies > ,
93
+ ) -> Config {
87
94
// Miri is rustc-like, so we create a default builder for rustc and modify it
88
95
let mut program = CommandBuilder :: rustc ( ) ;
89
96
program. program = miri_path ( ) ;
@@ -118,7 +125,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
118
125
// keep in sync with `./miri run`
119
126
config. comment_defaults . base ( ) . add_custom ( "edition" , Edition ( "2021" . into ( ) ) ) ;
120
127
121
- if with_dependencies {
128
+ if let Some ( WithDependencies { } ) = with_dependencies {
122
129
config. comment_defaults . base ( ) . set_custom ( "dependencies" , DependencyBuilder {
123
130
program : CommandBuilder {
124
131
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
@@ -145,7 +152,20 @@ fn run_tests(
145
152
with_dependencies : bool ,
146
153
tmpdir : & Path ,
147
154
) -> Result < ( ) > {
155
+ // Handle command-line arguments.
156
+ let mut args = ui_test:: Args :: test ( ) ?;
157
+ args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
158
+
159
+ let with_dependencies = with_dependencies. then_some ( WithDependencies { } ) ;
160
+
148
161
let mut config = miri_config ( target, path, mode, with_dependencies) ;
162
+ config. with_args ( & args) ;
163
+ config. bless_command = Some ( "./miri test --bless" . into ( ) ) ;
164
+
165
+ if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
166
+ assert ! ( !args. bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
167
+ config. output_conflict_handling = OutputConflictHandling :: Ignore ;
168
+ }
149
169
150
170
// Add a test env var to do environment communication tests.
151
171
config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
@@ -181,16 +201,6 @@ fn run_tests(
181
201
config. program . args . push ( flag) ;
182
202
}
183
203
184
- // Handle command-line arguments.
185
- let mut args = ui_test:: Args :: test ( ) ?;
186
- args. bless |= env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
187
- config. with_args ( & args) ;
188
- config. bless_command = Some ( "./miri test --bless" . into ( ) ) ;
189
-
190
- if env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) {
191
- assert ! ( !args. bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time" ) ;
192
- config. output_conflict_handling = OutputConflictHandling :: Ignore ;
193
- }
194
204
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
195
205
ui_test:: run_tests_generic (
196
206
// Only run one test suite. In the future we can add all test suites to one `Vec` and run
@@ -326,7 +336,7 @@ fn main() -> Result<()> {
326
336
}
327
337
328
338
fn run_dep_mode ( target : String , args : impl Iterator < Item = OsString > ) -> Result < ( ) > {
329
- let mut config = miri_config ( & target, "" , Mode :: RunDep , /* with dependencies */ true ) ;
339
+ let mut config = miri_config ( & target, "" , Mode :: RunDep , Some ( WithDependencies { } ) ) ;
330
340
config. comment_defaults . base ( ) . custom . remove ( "edition" ) ; // `./miri` adds an `--edition` in `args`, so don't set it twice
331
341
config. fill_host_and_target ( ) ?;
332
342
config. program . args = args. collect ( ) ;
0 commit comments