Skip to content

Commit 305cb25

Browse files
authored
Fixed temporary folder detection on MacOS (#3817)
1 parent b104788 commit 305cb25

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
* Fixed UB when freeing strings received from JS if not using the default allocator.
3737
[#3808](https://github.com/rustwasm/wasm-bindgen/pull/3808)
3838

39+
* Fixed temporary folder detection by `wasm-bindgen-test-runner` on MacOS.
40+
[#3817](https://github.com/rustwasm/wasm-bindgen/pull/3817)
41+
3942
## [0.2.90](https://github.com/rustwasm/wasm-bindgen/compare/0.2.89...0.2.90)
4043

4144
Released 2024-01-06

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,18 @@ fn main() -> anyhow::Result<()> {
8888
// - a tmp directory, generated by rustdoc
8989
// we would like a directory we have write access to. if we assume cargo-like directories,
9090
// we end up with the path `/wbg-out`
91-
let tmpdir = if wasm_file_to_test
92-
.to_string_lossy()
93-
.starts_with("/tmp/rustdoc")
94-
{
95-
wasm_file_to_test.parent() // chop off the file name and give us the /tmp/rustdoc<hash> directory
96-
} else {
97-
wasm_file_to_test
98-
.parent() // chop off file name
99-
.and_then(|p| p.parent()) // chop off `deps`
100-
.and_then(|p| p.parent()) // chop off `debug`
101-
}
102-
.map(|p| p.join(format!("wbg-tmp-{}", file_name)))
103-
.ok_or_else(|| anyhow!("file to test doesn't follow the expected Cargo conventions"))?;
91+
let wasm_file_str = wasm_file_to_test.to_string_lossy();
92+
let tmpdir =
93+
if wasm_file_str.starts_with("/tmp/rustdoc") || wasm_file_str.starts_with("/var/folders") {
94+
wasm_file_to_test.parent() // chop off the file name and give us the /tmp/rustdoc<hash> directory
95+
} else {
96+
wasm_file_to_test
97+
.parent() // chop off file name
98+
.and_then(|p| p.parent()) // chop off `deps`
99+
.and_then(|p| p.parent()) // chop off `debug`
100+
}
101+
.map(|p| p.join(format!("wbg-tmp-{}", file_name)))
102+
.ok_or_else(|| anyhow!("file to test doesn't follow the expected Cargo conventions"))?;
104103

105104
// Make sure there's no stale state from before
106105
drop(fs::remove_dir_all(&tmpdir));

0 commit comments

Comments
 (0)