Repository navigation
test(ffi): find the target directory when cargo did not make it - #169
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
crates/emberwave-ffi/tests/exports.rs(D73) finds the target directory byCACHEDIR.TAG, which cargo writes only into a directory it creates itself. WithCARGO_TARGET_DIRpointing at a directory that already existed (an empty one frommktemp -d, say) the test panicked with "the test runs below a target directory", although its doc comment says it works whateverCARGO_TARGET_DIRis. 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 exportspasses with the default target directory and withCARGO_TARGET_DIRset to an empty existing directory (it has.rustc_info.jsonand noCACHEDIR.TAG). fmt and clippy with-D warningspass. CI runs the test on macOS and Linux.