@@ -82,9 +82,16 @@ fn build_native_lib() -> PathBuf {
82
82
native_lib_path
83
83
}
84
84
85
+ struct WithDependencies { }
86
+
85
87
/// Does *not* set any args or env vars, since it is shared between the test runner and
86
88
/// 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 {
88
95
// Miri is rustc-like, so we create a default builder for rustc and modify it
89
96
let mut program = CommandBuilder :: rustc ( ) ;
90
97
program. program = miri_path ( ) ;
@@ -119,7 +126,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
119
126
// keep in sync with `./miri run`
120
127
config. comment_defaults . base ( ) . add_custom ( "edition" , Edition ( "2021" . into ( ) ) ) ;
121
128
122
- if with_dependencies {
129
+ if let Some ( WithDependencies { } ) = with_dependencies {
123
130
config. comment_defaults . base ( ) . set_custom ( "dependencies" , DependencyBuilder {
124
131
program : CommandBuilder {
125
132
// 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(
146
153
with_dependencies : bool ,
147
154
tmpdir : & Path ,
148
155
) -> 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
+
149
162
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
+ }
150
170
151
171
// Add a test env var to do environment communication tests.
152
172
config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
@@ -182,16 +202,6 @@ fn run_tests(
182
202
config. program . args . push ( flag) ;
183
203
}
184
204
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
- }
195
205
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
196
206
ui_test:: run_tests_generic (
197
207
// 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<()> {
327
337
}
328
338
329
339
fn 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 { } ) ) ;
331
341
config. comment_defaults . base ( ) . custom . remove ( "edition" ) ; // `./miri` adds an `--edition` in `args`, so don't set it twice
332
342
config. fill_host_and_target ( ) ?;
333
343
config. program . args = args. collect ( ) ;
0 commit comments