From ab91e90e588ebdc16c7aabdf6dcd5ad9433ee6c1 Mon Sep 17 00:00:00 2001 From: harry Date: Wed, 18 Nov 2026 20:05:35 +0900 Subject: [PATCH] test(ffi): find the target directory when cargo did not make it The export test locates the target directory by the CACHEDIR.TAG that cargo writes, which it does only into a directory it creates itself. With CARGO_TARGET_DIR set to a directory that already existed, an empty one from mktemp for example, the test panicked with "the test runs below a target directory". It now also takes a directory that holds .rustc_info.json, which cargo writes into any target directory. Found by a docs review that ran the test with such a directory; checked with the default directory and with an empty one. Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42 --- crates/emberwave-ffi/tests/exports.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/emberwave-ffi/tests/exports.rs b/crates/emberwave-ffi/tests/exports.rs index 21f1ada..ac3d374 100644 --- a/crates/emberwave-ffi/tests/exports.rs +++ b/crates/emberwave-ffi/tests/exports.rs @@ -66,10 +66,13 @@ struct Layout { fn layout() -> Layout { let exe = std::env::current_exe().expect("the test's path is known"); - // The outermost directory that cargo marked as a target directory. + // The outermost directory that cargo marked as a target directory: with + // CACHEDIR.TAG where cargo made the directory, and with .rustc_info.json, + // which it writes into a directory that was there already (an empty + // CARGO_TARGET_DIR from mktemp, say). let target_dir = exe .ancestors() - .filter(|dir| dir.join("CACHEDIR.TAG").exists()) + .filter(|dir| dir.join("CACHEDIR.TAG").exists() || dir.join(".rustc_info.json").exists()) .last() .expect("the test runs below a target directory") .to_path_buf();