@@ -13,7 +13,7 @@ use ui_test::custom_flags::edition::Edition;
13
13
use ui_test:: dependencies:: DependencyBuilder ;
14
14
use ui_test:: per_test_config:: TestConfig ;
15
15
use 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} ;
17
17
18
18
#[ derive( Copy , Clone , Debug ) ]
19
19
enum Mode {
@@ -82,9 +82,18 @@ fn build_native_lib() -> PathBuf {
82
82
native_lib_path
83
83
}
84
84
85
+ struct WithDependencies {
86
+ bless : bool ,
87
+ }
88
+
85
89
/// Does *not* set any args or env vars, since it is shared between the test runner and
86
90
/// 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 {
88
97
// Miri is rustc-like, so we create a default builder for rustc and modify it
89
98
let mut program = CommandBuilder :: rustc ( ) ;
90
99
program. program = miri_path ( ) ;
@@ -119,7 +128,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
119
128
// keep in sync with `./miri run`
120
129
config. comment_defaults . base ( ) . add_custom ( "edition" , Edition ( "2021" . into ( ) ) ) ;
121
130
122
- if with_dependencies {
131
+ if let Some ( WithDependencies { bless } ) = with_dependencies {
123
132
config. comment_defaults . base ( ) . set_custom ( "dependencies" , DependencyBuilder {
124
133
program : CommandBuilder {
125
134
// 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) ->
134
143
} ,
135
144
crate_manifest_path : Path :: new ( "test_dependencies" ) . join ( "Cargo.toml" ) ,
136
145
build_std : None ,
146
+ bless_lockfile : bless,
137
147
} ) ;
138
148
}
139
149
config
@@ -146,7 +156,20 @@ fn run_tests(
146
156
with_dependencies : bool ,
147
157
tmpdir : & Path ,
148
158
) -> 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
+
149
165
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
+ }
150
173
151
174
// Add a test env var to do environment communication tests.
152
175
config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
@@ -182,16 +205,6 @@ fn run_tests(
182
205
config. program . args . push ( flag) ;
183
206
}
184
207
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
208
eprintln ! ( " Compiler: {}" , config. program. display( ) ) ;
196
209
ui_test:: run_tests_generic (
197
210
// 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<()> {
327
340
}
328
341
329
342
fn 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 } ) ) ;
331
345
config. comment_defaults . base ( ) . custom . remove ( "edition" ) ; // `./miri` adds an `--edition` in `args`, so don't set it twice
332
346
config. fill_host_and_target ( ) ?;
333
347
config. program . args = args. collect ( ) ;
0 commit comments