I have some tests that load data files from the source tree. I’ve been building a path to them starting with
PathBuf::from(file!()) and that seems to work well (example). However, I recently added a subcrate to my project, and when I try to run its tests using
cargo test -p subcrate, this method fails, because
subcrate/src/foo.rs, but the cwd when running the tests is in
Is there any way to reliably do this such that it works in the
cargo test -p case? I know I could use
include_bytes, but I have methods that take a
Path and I’d like to write tests for them as well.