Skip to content

fix(tests): isolate integration caches from user state#1067

Open
tmonestudio wants to merge 1 commit into
DeusData:mainfrom
tmonestudio:codex/test-isolate-cache
Open

fix(tests): isolate integration caches from user state#1067
tmonestudio wants to merge 1 commit into
DeusData:mainfrom
tmonestudio:codex/test-isolate-cache

Conversation

@tmonestudio

Copy link
Copy Markdown

What does this PR do?

Prevents the C test runner from reading or writing a user's real codebase-memory cache.

Several integration fixtures exercise the production index_repository flow. The production cache resolver prefers CBM_CACHE_DIR, while older fixtures derive the expected database path from HOME/.cache/codebase-memory-mcp. When the runner inherited a real cache, early assertion returns could leave fixture databases behind. Setting only CBM_CACHE_DIR was also insufficient because those legacy paths diverged.

Fix

  • create a private temporary HOME for every normal test-runner process;
  • clear inherited CBM_CACHE_DIR, so production code and legacy fixtures converge on the private HOME cache;
  • delete the sentinel tree with atexit, including after early test returns;
  • make the lang-contract helper honor an explicit CBM_CACHE_DIR when a test intentionally sets one.

Worker/probe subprocess modes still exit before the sentinel setup.

Validation

Windows GCC build after rebasing onto current main:

  • full C runner: 5831 passed, 22 skipped;
  • production-cache sentinel: 501 DB files before, 501 after;
  • added files: 0;
  • removed files: 0.

The same run previously left cbm_seq898_*, cbm_lc_*, and cbm_fcw_* fixture databases in the inherited cache.

Checklist

  • Every commit is signed off (git commit -s)
  • Full C test runner passes locally
  • Full lint (left to CI)
  • Behavior validated with a before/after cache sentinel

Run the test process under a private temporary HOME and clear inherited CBM_CACHE_DIR so production index paths and legacy fixtures resolve to the same isolated cache.

Make lang-contract fixtures honor an explicit cache override and remove the sentinel tree at process exit, including after early assertion returns.

Validated on Windows with the full runner: 5828 passed, 22 skipped; a 500-project user cache had zero files added or removed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: tmonestudio <tmonestudio@users.noreply.github.com>
@tmonestudio tmonestudio requested a review from DeusData as a code owner July 12, 2026 23: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