test(ck-engine): guard empty-corpus lexical rebuild - #185
Conversation
Add a regression test covering the transition from an empty corpus (which builds an empty tantivy index) to a populated one: the corpus fingerprint changes, so the next lexical search must rebuild and surface the new files rather than trusting the empty index. The test uses a plain #[tokio::test] with a TempDir-scoped .ck, matching the other lexical-search tests: the unique temp path keys its own index (in-tree, or a path-hashed subdir when CK_INDEX_DIR relocates it), so it stays isolated without serial_test or removing the CK_INDEX_DIR env var.
|
CI is red here, but the two failures are in What I checked locally, on Linux and macOS, using CI's exact invocation (
So I can't reproduce it, and I don't think it's caused by this change. Both tests are I don't have rerun rights on this repo. If you re-run the job and it's still red, tell me and I'll dig in properly rather than assume it's environmental. |
Test-only, no production change.
A
--lexsearch over a directory with no indexable files builds an empty tantivy index. When real files appear later the corpus fingerprint changes, so the next search must rebuild rather than trust the empty stub — otherwise that directory reports no matches indefinitely. The rebuild logic is already inlexical_search; this pins the empty-corpus corner of it, which is the case I actually hit.Verified non-vacuous: dropping the fingerprint comparison from the freshness check (
let is_fresh = tantivy_index_path.exists();) fails the test withempty tantivy stub was trusted; expected a rebuild to find the new file.Uses a unique
TempDir, which keys its own index, so it needs noserial_testor env manipulation to stay isolated.cargo test -p ck-engine(41),clippy,fmtclean.