Skip to content

Commit 4eea02e

Browse files
committed
Normalize MIRI_TEMP before using it
1 parent 9e6320f commit 4eea02e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/run-pass/fs.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,19 @@ fn main() {
2929
}
3030

3131
fn tmp() -> PathBuf {
32-
std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
32+
std::env::var("MIRI_TEMP")
33+
.map(|tmp| {
34+
// MIRI_TEMP is set outside of our emulated
35+
// program, so it may have path separators that don't
36+
// correspond to our target platform. We normalize them here
37+
// before constructing a `PathBuf`
38+
39+
#[cfg(windows)]
40+
return PathBuf::from(tmp.replace("/", "\\"));
41+
42+
#[cfg(not(windows))]
43+
return PathBuf::from(tmp.replace("\\", "/"));
44+
}).unwrap_or_else(|_| std::env::temp_dir())
3345
}
3446

3547
/// Prepare: compute filename and make sure the file does not exist.

0 commit comments

Comments
 (0)