Skip to content

test(ffi): find the target directory when cargo did not make it - #169

Merged
with-developer merged 1 commit into
mainfrom
fix/exports-test-target-dir
Nov 18, 2026
Merged

with-developer merged 1 commit into
mainfrom
fix/exports-test-target-dir

Conversation

@with-developer

Copy link
Copy Markdown
Owner

Purpose

crates/emberwave-ffi/tests/exports.rs (D73) finds the target directory by CACHEDIR.TAG, which cargo writes only into a directory it creates itself. With CARGO_TARGET_DIR pointing at a directory that already existed (an empty one from mktemp -d, say) the test panicked with "the test runs below a target directory", although its doc comment says it works whatever CARGO_TARGET_DIR is. A docs review found it by running the test that way.

Changes

The test also accepts a directory that holds .rustc_info.json, which cargo writes into any target directory it uses. One line of logic and a comment.

Testing

cargo test -p emberwave-ffi --test exports passes with the default target directory and with CARGO_TARGET_DIR set to an empty existing directory (it has .rustc_info.json and no CACHEDIR.TAG). fmt and clippy with -D warnings pass. CI runs the test on macOS and Linux.

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
@with-developer
with-developer merged commit fc53344 into main Nov 18, 2026
7 checks passed
@with-developer
with-developer deleted the fix/exports-test-target-dir branch November 18, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant