@@ -79,13 +79,6 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
79
79
program. args . push ( flag) ;
80
80
}
81
81
82
- // Add a test env var to do environment communication tests.
83
- program. envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
84
-
85
- // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
86
- let miri_temp = env:: var_os ( "MIRI_TEMP" ) . unwrap_or_else ( || env:: temp_dir ( ) . into ( ) ) ;
87
- program. envs . push ( ( "MIRI_TEMP" . into ( ) , Some ( miri_temp) ) ) ;
88
-
89
82
let mut config = Config {
90
83
target : Some ( target. to_owned ( ) ) ,
91
84
stderr_filters : STDERR . clone ( ) ,
@@ -116,9 +109,21 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
116
109
config
117
110
}
118
111
119
- fn run_tests ( mode : Mode , path : & str , target : & str , with_dependencies : bool ) -> Result < ( ) > {
112
+ fn run_tests (
113
+ mode : Mode ,
114
+ path : & str ,
115
+ target : & str ,
116
+ with_dependencies : bool ,
117
+ tmpdir : & Path ,
118
+ ) -> Result < ( ) > {
120
119
let mut config = test_config ( target, path, mode, with_dependencies) ;
121
120
121
+ // Add a test env var to do environment communication tests.
122
+ config. program . envs . push ( ( "MIRI_ENV_VAR_TEST" . into ( ) , Some ( "0" . into ( ) ) ) ) ;
123
+
124
+ // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
125
+ config. program . envs . push ( ( "MIRI_TEMP" . into ( ) , Some ( tmpdir. to_owned ( ) . into ( ) ) ) ) ;
126
+
122
127
// Handle command-line arguments.
123
128
let args = ui_test:: Args :: test ( ) ?;
124
129
let default_bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
@@ -211,15 +216,21 @@ enum Dependencies {
211
216
212
217
use Dependencies :: * ;
213
218
214
- fn ui ( mode : Mode , path : & str , target : & str , with_dependencies : Dependencies ) -> Result < ( ) > {
219
+ fn ui (
220
+ mode : Mode ,
221
+ path : & str ,
222
+ target : & str ,
223
+ with_dependencies : Dependencies ,
224
+ tmpdir : & Path ,
225
+ ) -> Result < ( ) > {
215
226
let msg = format ! ( "## Running ui tests in {path} against miri for {target}" ) ;
216
227
eprintln ! ( "{}" , msg. green( ) . bold( ) ) ;
217
228
218
229
let with_dependencies = match with_dependencies {
219
230
WithDependencies => true ,
220
231
WithoutDependencies => false ,
221
232
} ;
222
- run_tests ( mode, path, target, with_dependencies)
233
+ run_tests ( mode, path, target, with_dependencies, tmpdir )
223
234
}
224
235
225
236
fn get_target ( ) -> String {
@@ -230,6 +241,7 @@ fn main() -> Result<()> {
230
241
ui_test:: color_eyre:: install ( ) ?;
231
242
232
243
let target = get_target ( ) ;
244
+ let tmpdir = tempfile:: Builder :: new ( ) . prefix ( "miri-uitest-" ) . tempdir ( ) ?;
233
245
234
246
let mut args = std:: env:: args_os ( ) ;
235
247
@@ -240,28 +252,31 @@ fn main() -> Result<()> {
240
252
}
241
253
}
242
254
243
- ui ( Mode :: Pass , "tests/pass" , & target, WithoutDependencies ) ?;
244
- ui ( Mode :: Pass , "tests/pass-dep" , & target, WithDependencies ) ?;
245
- ui ( Mode :: Panic , "tests/panic" , & target, WithDependencies ) ?;
255
+ ui ( Mode :: Pass , "tests/pass" , & target, WithoutDependencies , tmpdir . path ( ) ) ?;
256
+ ui ( Mode :: Pass , "tests/pass-dep" , & target, WithDependencies , tmpdir . path ( ) ) ?;
257
+ ui ( Mode :: Panic , "tests/panic" , & target, WithDependencies , tmpdir . path ( ) ) ?;
246
258
ui (
247
259
Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
248
260
"tests/fail" ,
249
261
& target,
250
262
WithoutDependencies ,
263
+ tmpdir. path ( ) ,
251
264
) ?;
252
265
ui (
253
266
Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
254
267
"tests/fail-dep" ,
255
268
& target,
256
269
WithDependencies ,
270
+ tmpdir. path ( ) ,
257
271
) ?;
258
272
if cfg ! ( target_os = "linux" ) {
259
- ui ( Mode :: Pass , "tests/extern-so/pass" , & target, WithoutDependencies ) ?;
273
+ ui ( Mode :: Pass , "tests/extern-so/pass" , & target, WithoutDependencies , tmpdir . path ( ) ) ?;
260
274
ui (
261
275
Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
262
276
"tests/extern-so/fail" ,
263
277
& target,
264
278
WithoutDependencies ,
279
+ tmpdir. path ( ) ,
265
280
) ?;
266
281
}
267
282
0 commit comments