Function get_base_test_dir

Source
pub fn get_base_test_dir() -> &'static Path
Expand description

Return a Path to a test-data directory inside the crate or workspace target/ directory

This function implicitly assumes the current executable resides within the target/ directory which is the case for test binaries. If it cannot find the target/ directory it will panic.

It prints diagnostic information to stderr.

The first time this is called in a process, it will remove any pre-existing test-data directory, then create a new directory. This design aims to leave test data available for inspection after a test run, while also ensuring all of the contents come from the same test process run. This function is thread-safe via OnceCell, which supports the primary use case of being used for multiple #[test] functions which may be invoked concurrently.