File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ fn get_target() -> String {
110110fn test_runner ( _tests : & [ & ( ) ] ) {
111111 // Add a test env var to do environment communication tests.
112112 std:: env:: set_var ( "MIRI_ENV_VAR_TEST" , "0" ) ;
113+ // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
114+ std:: env:: set_var ( "MIRI_TEMP" , std:: env:: temp_dir ( ) ) ;
113115
114116 let target = get_target ( ) ;
115117 miri_pass ( "tests/run-pass" , & target) ;
Original file line number Diff line number Diff line change @@ -16,19 +16,21 @@ fn main() {
1616 test_directory ( ) ;
1717}
1818
19+ fn tmp ( ) -> PathBuf {
20+ std:: env:: var ( "MIRI_TEMP" ) . map ( PathBuf :: from) . unwrap_or_else ( |_| std:: env:: temp_dir ( ) )
21+ }
22+
1923/// Prepare: compute filename and make sure the file does not exist.
2024fn prepare ( filename : & str ) -> PathBuf {
21- let tmp = std:: env:: temp_dir ( ) ;
22- let path = tmp. join ( filename) ;
25+ let path = tmp ( ) . join ( filename) ;
2326 // Clean the paths for robustness.
2427 remove_file ( & path) . ok ( ) ;
2528 path
2629}
2730
2831/// Prepare directory: compute directory name and make sure it does not exist.
2932fn prepare_dir ( dirname : & str ) -> PathBuf {
30- let tmp = std:: env:: temp_dir ( ) ;
31- let path = tmp. join ( & dirname) ;
33+ let path = tmp ( ) . join ( & dirname) ;
3234 // Clean the directory for robustness.
3335 remove_dir_all ( & path) . ok ( ) ;
3436 path
Original file line number Diff line number Diff line change 22// compile-flags: -Zmiri-disable-isolation
33
44#![ feature( rustc_private) ]
5+ #![ allow( unused) ] // necessary on macos due to conditional compilation
6+
7+ use std:: path:: PathBuf ;
58
6- #[ allow( unused) ] // necessary on macos due to conditional compilation
79extern crate libc;
810
11+ fn tmp ( ) -> PathBuf {
12+ std:: env:: var ( "MIRI_TEMP" ) . map ( PathBuf :: from) . unwrap_or_else ( |_| std:: env:: temp_dir ( ) )
13+ }
14+
915#[ cfg( not( target_os = "macos" ) ) ]
1016fn test_posix_fadvise ( ) {
1117 use std:: convert:: TryInto ;
12- use std:: env:: temp_dir;
1318 use std:: fs:: { File , remove_file} ;
1419 use std:: io:: Write ;
1520 use std:: os:: unix:: io:: AsRawFd ;
1621
17- let path = temp_dir ( ) . join ( "miri_test_libc.txt" ) ;
22+ let path = tmp ( ) . join ( "miri_test_libc.txt" ) ;
1823 // Cleanup before test
1924 remove_file ( & path) . ok ( ) ;
2025
You can’t perform that action at this time.
0 commit comments