Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions tests/pass-dep/shims/libc-fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fn main() {
test_file_open_unix_extra_third_arg();
#[cfg(target_os = "linux")]
test_o_tmpfile_flag();
test_tempfile();
}

fn tmp() -> PathBuf {
Expand Down Expand Up @@ -167,9 +166,3 @@ fn test_o_tmpfile_flag() {
.raw_os_error(),
);
}

/// Test that the [`tempfile`] crate is compatible with miri.
fn test_tempfile() {
let dir_path = tmp();
tempfile::tempfile_in(dir_path).unwrap();
}
34 changes: 34 additions & 0 deletions tests/pass-dep/tempfile.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//@ignore-target-windows: no libc on Windows
//@compile-flags: -Zmiri-disable-isolation

//! Test that the [`tempfile`] crate is compatible with miri.
fn main() {
test_tempfile();
test_tempfile_in();
}

fn tmp() -> PathBuf {
std::env::var("MIRI_TEMP")
.map(|tmp| {
// MIRI_TEMP is set outside of our emulated
// program, so it may have path separators that don't
// correspond to our target platform. We normalize them here
// before constructing a `PathBuf`

#[cfg(windows)]
return PathBuf::from(tmp.replace("/", "\\"));

#[cfg(not(windows))]
return PathBuf::from(tmp.replace("\\", "/"));
})
.unwrap_or_else(|_| std::env::temp_dir())
}

fn test_tempfile() {
tempfile::tempfile().unwrap();
}

fn test_tempfile_in() {
let dir_path = tmp();
tempfile::tempfile_in(dir_path).unwrap();
}