Skip to content

Make CLI doctor tests hermetic (isolate state_dir/cache_dir)#75

Merged
cgraf78 merged 1 commit into
mainfrom
fix-cli-test-hermeticity
Jul 1, 2026
Merged

Make CLI doctor tests hermetic (isolate state_dir/cache_dir)#75
cgraf78 merged 1 commit into
mainfrom
fix-cli-test-hermeticity

Conversation

@cgraf78

@cgraf78 cgraf78 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Give the doctor CLI tests isolated state_dir/cache_dir so they stop
reading the live machine's classifier stamps and index cache.

write_data_config (and two inline doctor-test configs) set only
data_dir, so state_dir/cache_dir fell back to
${XDG_STATE_HOME:-~/.local/state} / ${XDG_CACHE_HOME:-~/.cache}.
doctor reads those (classifier stamps and the scoped index), so on any
machine with real hive-memory state the tests saw extra warnings and
failed with machine-dependent results.

  • write_data_config now writes state_dir/cache_dir under the
    config's temp dir, mirroring write_config
  • convert the doctor-project-binding inline config to reuse
    write_data_config
  • add state_dir/cache_dir to the two remaining doctor inline configs
    (doctor-manifest-permissions, doctor-agent-broad-access)

Test-only change.

Testing

  • cargo test --test cli: 137 passed, 0 failed (the doctor tests
    previously failed on this machine, which has live classifier state)
  • cargo fmt --check clean
  • cargo clippy --test cli --all-features -- -D warnings clean

Summary
give the doctor CLI tests isolated `state_dir`/`cache_dir` so they stop
reading the live machine's classifier stamps and index cache.

`write_data_config` (and two inline doctor-test configs) set only
`data_dir`, so `state_dir`/`cache_dir` fell back to
`${XDG_STATE_HOME:-~/.local/state}` / `${XDG_CACHE_HOME:-~/.cache}`.
`doctor` reads those (classifier stamps, scoped index), so on any
machine with real hive-memory state the tests saw extra warnings and
failed — machine-dependent results.

- `write_data_config` now writes `state_dir`/`cache_dir` under the
  config's temp dir, mirroring `write_config`
- convert the `doctor-project-binding` inline config to reuse
  `write_data_config`
- add `state_dir`/`cache_dir` to the two remaining doctor inline configs
  (`doctor-manifest-permissions`, `doctor-agent-broad-access`)

Testing
- cargo test --test cli: 137 passed, 0 failed (previously the doctor
  tests failed on this machine, which has live classifier state)
- cargo fmt --check clean; cargo clippy --test cli -- -D warnings clean
@cgraf78 cgraf78 merged commit be411fe into main Jul 1, 2026
15 checks passed
@cgraf78 cgraf78 deleted the fix-cli-test-hermeticity branch July 1, 2026 20:24
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