Repository navigation
fix(test): isolate tests from real data dir and bound vector index lock wait - #589
Merged
Merged
Conversation
…dex lock wait (#587) Unit tests now resolve the CodeCora data root to a process-wide scratch dir unless CODECORA_HOME is set, so index/watch tests no longer open the developer's real global vector index or hang behind another cora process. acquire_file_lock polls try_lock for 15s then errors naming the lock path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
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.
What
~/.codecora: without an explicitCODECORA_HOME,data_dir::codecora_home()(undercfg(test)only) resolves to one process-wide scratch tempdir. The resolution rule is split into a pureresolve_homefn.vector::acquire_file_locknow pollstry_lock_exclusivefor up to 15s, then fails withtimed out ... waiting for the vector index lock at <path>; another cora process may be holding itinstead of blocking forever.CODECORA_HOME(removed the env-mutating tests and their racyENV_LOCK).Why
Index/watch tests reach
embed_project->load_or_create_usearch->flockon the real global vector index, so any runningcoraprocess (e.g. a longcora scan) hung them forever, and they polluted the real data dir. A per-process scratch dir needs no env mutation (safe under parallel tests) and matches the process-globalVECTOR_CACHE. Existing callers already degrade on the new error:index_project_with_idtreats embedding failure as non-fatal andensure_vector_cachefalls back to FTS-only search. User-visible change: a contended index lock now errors after 15s rather than hanging.Testing
index::vector::tests::locked_index_errors_instead_of_blocking(holds the lock, asserts a timeout error naming the path, then re-acquires after release).data_dirtests assert resolved dirs are under the scratch home, never the real one.cargo test --features tree-sitter --bin cora -- index:: commands::watchpasses while a straycora scanholds the real lock; fullcargo test --features tree-sitterpasses; fmt and clippy-D warningsclean.Closes #587
🤖 Generated with Claude Code