Skip to content

Commit

Permalink
Make canonicalization optional in glob!
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jan 6, 2023
1 parent 44cf2da commit b319043
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to insta and cargo-insta are documented here.

## 1.26.0

- Make canonicalization in `glob!` optional to better support WASI.

## 1.25.0

- Added a way to disable the undiscoverable snapshots warning. By
Expand Down
6 changes: 4 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,10 @@ macro_rules! glob {
.join(file!())
.parent()
.unwrap()
.canonicalize()
.unwrap_or_else(|e| panic!("failed to canonicalize insta::glob! base path: {}", e));
.to_path_buf();
// we try to canonicalize but on some platforms (eg: wasm) that might not work, so
// we instead silently fall back.
let base = base.canonicalize().unwrap_or_else(|_| base);
$crate::_macro_support::glob_exec(env!("CARGO_MANIFEST_DIR"), &base, $glob, $closure);
}};
}

0 comments on commit b319043

Please sign in to comment.