@@ -79,13 +79,6 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
7979 program. args . push ( flag) ;
8080 }
8181
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-
8982 let mut config = Config {
9083 target : Some ( target. to_owned ( ) ) ,
9184 stderr_filters : STDERR . clone ( ) ,
@@ -116,9 +109,21 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
116109 config
117110}
118111
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 < ( ) > {
120119 let mut config = test_config ( target, path, mode, with_dependencies) ;
121120
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+
122127 // Handle command-line arguments.
123128 let args = ui_test:: Args :: test ( ) ?;
124129 let default_bless = env:: var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
@@ -211,15 +216,21 @@ enum Dependencies {
211216
212217use Dependencies :: * ;
213218
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 < ( ) > {
215226 let msg = format ! ( "## Running ui tests in {path} against miri for {target}" ) ;
216227 eprintln ! ( "{}" , msg. green( ) . bold( ) ) ;
217228
218229 let with_dependencies = match with_dependencies {
219230 WithDependencies => true ,
220231 WithoutDependencies => false ,
221232 } ;
222- run_tests ( mode, path, target, with_dependencies)
233+ run_tests ( mode, path, target, with_dependencies, tmpdir )
223234}
224235
225236fn get_target ( ) -> String {
@@ -230,6 +241,7 @@ fn main() -> Result<()> {
230241 ui_test:: color_eyre:: install ( ) ?;
231242
232243 let target = get_target ( ) ;
244+ let tmpdir = tempfile:: Builder :: new ( ) . prefix ( "miri-compiletest-" ) . tempdir ( ) ?;
233245
234246 let mut args = std:: env:: args_os ( ) ;
235247
@@ -240,28 +252,31 @@ fn main() -> Result<()> {
240252 }
241253 }
242254
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 ( ) ) ?;
246258 ui (
247259 Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
248260 "tests/fail" ,
249261 & target,
250262 WithoutDependencies ,
263+ tmpdir. path ( ) ,
251264 ) ?;
252265 ui (
253266 Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
254267 "tests/fail-dep" ,
255268 & target,
256269 WithDependencies ,
270+ tmpdir. path ( ) ,
257271 ) ?;
258272 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 ( ) ) ?;
260274 ui (
261275 Mode :: Fail { require_patterns : true , rustfix : RustfixMode :: Disabled } ,
262276 "tests/extern-so/fail" ,
263277 & target,
264278 WithoutDependencies ,
279+ tmpdir. path ( ) ,
265280 ) ?;
266281 }
267282
0 commit comments