Skip to content

Commit

Permalink
Fixed temporary folder detection on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Jan 30, 2024
1 parent fb518d3 commit ada4d7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* Fixed UB when freeing strings received from JS if not using the default allocator.
[#3808](https://github.com/rustwasm/wasm-bindgen/pull/3808)

* Fixed temporary folder detection by `wasm-bindgen-test-runner` on MacOS.
[#3817](https://github.com/rustwasm/wasm-bindgen/pull/3817)

## [0.2.90](https://github.com/rustwasm/wasm-bindgen/compare/0.2.89...0.2.90)

Released 2024-01-06
Expand Down
25 changes: 12 additions & 13 deletions crates/cli/src/bin/wasm-bindgen-test-runner/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,18 @@ fn main() -> anyhow::Result<()> {
// - a tmp directory, generated by rustdoc
// we would like a directory we have write access to. if we assume cargo-like directories,
// we end up with the path `/wbg-out`
let tmpdir = if wasm_file_to_test
.to_string_lossy()
.starts_with("/tmp/rustdoc")
{
wasm_file_to_test.parent() // chop off the file name and give us the /tmp/rustdoc<hash> directory
} else {
wasm_file_to_test
.parent() // chop off file name
.and_then(|p| p.parent()) // chop off `deps`
.and_then(|p| p.parent()) // chop off `debug`
}
.map(|p| p.join(format!("wbg-tmp-{}", file_name)))
.ok_or_else(|| anyhow!("file to test doesn't follow the expected Cargo conventions"))?;
let wasm_file_str = wasm_file_to_test.to_string_lossy();
let tmpdir =
if wasm_file_str.starts_with("/tmp/rustdoc") || wasm_file_str.starts_with("/var/folders") {
wasm_file_to_test.parent() // chop off the file name and give us the /tmp/rustdoc<hash> directory
} else {
wasm_file_to_test
.parent() // chop off file name
.and_then(|p| p.parent()) // chop off `deps`
.and_then(|p| p.parent()) // chop off `debug`
}
.map(|p| p.join(format!("wbg-tmp-{}", file_name)))
.ok_or_else(|| anyhow!("file to test doesn't follow the expected Cargo conventions"))?;

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

0 comments on commit ada4d7c

Please sign in to comment.