test(memdir): serialize hosted-memory path tests against the home env lock - #174
Merged
Conversation
… lock hosted_memory_ignores_local_checkout_path (and two sibling hosted-path tests) resolved home-dependent memory paths without holding COVEN_HOME_ENV_LOCK, so a parallel test's COVEN_CODE_TEST_HOME set_var/remove_var could flip the home between two resolutions and make equal-path assertions fail intermittently in CI (observed in Actions run 30271680167). Every mutator already held the lock; these were the only unlocked readers — and the config alias CONFIG_HOME_ENV_LOCK is a re-export of the same mutex, so one lock covers all. Each test now takes the shared lock and pins a private tempdir home for its duration (restored after), matching the module's mutating-test convention, so assertions are hermetic as well as serialized. Verified: memdir:: module 41/41 across repeated runs. Cave bead cave-r78ad. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR addresses intermittent CI flakiness in memdir hosted-memory path tests by serializing home-directory resolution against other tests that mutate COVEN_CODE_TEST_HOME, ensuring path resolution and assertions run against a stable, test-private home.
Changes:
- Added
COVEN_HOME_ENV_LOCKacquisition around hosted-memory path resolution in three tests. - Pinned
COVEN_CODE_TEST_HOMEto a privatetempdirfor the duration of each affected test (restoring afterward). - Documented the race scenario and why serialization is required.
Suppressed comments (2)
src-rust/crates/core/src/memdir.rs:1142
COVEN_CODE_TEST_HOMEis restored after the assertions. If an assertion panics, the env var stays set and can affect other tests that run after this one. Restore the env var before assertions (or use a Drop guard) so failures don’t leak process-global state.
match original_test_home {
Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
}
src-rust/crates/core/src/memdir.rs:1244
COVEN_CODE_TEST_HOMEis restored only after assertions. If an assertion panics, the env var stays set and can leak into other tests. Restore the env var before running assertions so failures don’t contaminate subsequent tests.
match original_test_home {
Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1075
to
+1078
| match original_test_home { | ||
| Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value), | ||
| None => std::env::remove_var("COVEN_CODE_TEST_HOME"), | ||
| } |
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.
Summary
Fixes the intermittent CI failure in
memdir::tests::hosted_memory_ignores_local_checkout_path(Actions run 30271680167; Cave bead cave-r78ad): the test — plus two sibling hosted-path tests — resolved home-dependent memory paths without holdingCOVEN_HOME_ENV_LOCK, so a parallel test'sCOVEN_CODE_TEST_HOMEset_var/remove_varcould flip the home between two resolutions and break equal-path assertions.The audit found every mutator already holds the lock (including claudemd's), and
CONFIG_HOME_ENV_LOCKis a re-export of the same mutex — one lock covers all; these three were the only unlocked readers. Each now takes the shared lock and pins a private tempdir home for its duration (restored after), matching the module's mutating-test convention, so the assertions are hermetic as well as serialized.Verification
memdir::module: 41/41 across repeated runs.cargo fmt --checkclean.🤖 Generated with Claude Code