Skip to main content

test_scratch_dir

Function test_scratch_dir 

Source
pub fn test_scratch_dir(manifest_dir: &str, tag: &str) -> PathBuf
Expand description

A unique, empty directory under the workspace target/test-output.

Never the system temporary directory: on Linux that is tmpfs, so a test writing a payload there writes it to RAM, and a failure leaves nothing under target to look at afterwards. apps/desktop-demo/tests/source_hygiene_aliases.rs enforces that across the workspace.

manifest_dir is the caller’s own env!("CARGO_MANIFEST_DIR"). Its last component names the subdirectory, so two crates asking for the same tag get different directories; the workspace root is found by walking up to the directory holding Cargo.lock rather than by counting .. hops, which differ per crate and are wrong the moment one moves.