fn test_runner(_tests: &[&()]) {
// Add a test env var to do environment communication tests.
std::env::set_var("MIRI_ENV_VAR_TEST", "0");
+ // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
+ std::env::set_var("MIRI_TEMP", std::env::temp_dir());
let target = get_target();
miri_pass("tests/run-pass", &target);
test_directory();
}
+fn tmp() -> PathBuf {
+ std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
+}
+
/// Prepare: compute filename and make sure the file does not exist.
fn prepare(filename: &str) -> PathBuf {
- let tmp = std::env::temp_dir();
- let path = tmp.join(filename);
+ let path = tmp().join(filename);
// Clean the paths for robustness.
remove_file(&path).ok();
path
/// Prepare directory: compute directory name and make sure it does not exist.
fn prepare_dir(dirname: &str) -> PathBuf {
- let tmp = std::env::temp_dir();
- let path = tmp.join(&dirname);
+ let path = tmp().join(&dirname);
// Clean the directory for robustness.
remove_dir_all(&path).ok();
path
// compile-flags: -Zmiri-disable-isolation
#![feature(rustc_private)]
+#![allow(unused)] // necessary on macos due to conditional compilation
+
+use std::path::PathBuf;
-#[allow(unused)] // necessary on macos due to conditional compilation
extern crate libc;
+fn tmp() -> PathBuf {
+ std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
+}
+
#[cfg(not(target_os = "macos"))]
fn test_posix_fadvise() {
use std::convert::TryInto;
- use std::env::temp_dir;
use std::fs::{File, remove_file};
use std::io::Write;
use std::os::unix::io::AsRawFd;
- let path = temp_dir().join("miri_test_libc.txt");
+ let path = tmp().join("miri_test_libc.txt");
// Cleanup before test
remove_file(&path).ok();