Closed akesson closed 4 years ago
Do you happen to be running this test as a crate not in the root of the cargo workspace?
I just ran into what looks to be the same error, due to the fact that glob!
computes the path as $CARGO_MANIFEST_DIR </> file!()
The problem seems to be that file!()
is relative to the workspace root manifest, and insta is assuming that it's relative to the $CARGO_MANIFEST_DIR
manifest (which I would've assumed, too, before tracking down this panic).
So in my case I have
$CARGO_MANIFEST_DIR = "D:\\repos\\cad97\\pegcel\\crates\\codegen"
file!() = "crates\\codegen\\tests\\snapshot.rs"
so instead of the glob having a base of the directory that the file is in, it has a base of effectively ../crates/codegen/tests
.
I don't know if there's a way to do exactly what we want here without cargo adding e.g. $CARGO_WORKSPACE_DIR
.
Would love to get this fixed. Right now I'm re-implementing the glob_exec
function in my code so I can use insta within a workspace.
If people don't mind using a git dependency in the meantime, you can use the fix in #123 directly:
insta = { git = "https://github.com/CAD97/insta.git", branch = "fix-119" }
@mitsuhiko, any estimate when we might be able to merge and publish that fix? Without it, it's completely impossible to use insta's glob support outside of the root-located crate in a workspace.
Love using insta! Thanks for doing it!
It's my 3rd day doing Rust, so maybe it's just me doing something wrong (sorry in that case).
I was running glob tests in a simple project setup and everything worked as a charm, but then I re-organized the project into a workspace to host more binaries/libraries and it stopped working.
This is the test (in a simplified format, the original stuff in comments):
But fails on the
glob!
line with:When checking the path:
Stacktrace
``` stack backtrace: 0: backtrace::backtrace::libunwind::trace at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86 1: backtrace::backtrace::trace_unsynchronized at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:78 3:Any ideas? It the full workspace setup info needed?