You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: stop CLI tests rewriting the real .mcp.json, align pre-push ruff with CI (#45)
* fix(tests): stop CLI tests rewriting the real .mcp.json
`setup_reaper._resolve_mcp_target()` picks its write target as the first
existing of $HOME/.mcp.json then cwd/.mcp.json. Under pytest cwd is the repo
root, so `test_success_moves_into_place` -- which invokes `setup-reaper
--install-dir <tmp> --yes` -- rewrote the developer's real project .mcp.json
with pytest tmpdir paths, pointing the reaper MCP server at a directory that
ceased to exist when the test finished. `--yes` skipped the confirmation that
would otherwise have caught it.
The existing autouse `_confine_writes_to_tmp` fixture missed this because it
only redirects PHANTOM_OUTPUT_DIR, and .mcp.json resolution never consults it.
Extend that fixture to redirect all three .mcp.json resolvers into tmp_path,
so no test can reach the real file regardless of which command it invokes.
Fixing it in the fixture rather than at each call site means new tests inherit
the protection. Tests that patch these resolvers themselves are unaffected --
mock.patch applies on top and restores afterward.
Extract `_mcp_candidates()` in uninstall.py so its scan (which feeds the
removal path) is redirectable the same way, instead of an inline literal.
Verified by reproducing: with the guard removed, the single test rewrites
.mcp.json with a fresh tmpdir; with it in place, 1041 passed / 47 skipped and
the file is byte-identical before and after.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* fix(ci): run ruff from dev deps in pre-push, matching CI
The hook ran `uv tool run ruff`, which resolves to the newest ruff available
rather than the `ruff>=0.15` pinned in dev dependencies. CI runs `uv run ruff`.
Once ruff 0.16 landed in the tool cache the two diverged: 0.16 widened its
default rule set, and since this project ships no [tool.ruff] config and relies
on those defaults, the hook reported 251 errors on a tree CI considers clean.
Switch the hook to `uv run` so local and CI enforce the same rules from the
same version. No source changes were needed -- the tree passes cleanly under
the pinned ruff 0.15.12.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* fix(tests): stop the guard triggering first-run auto-setup in CI
The .mcp.json guard broke CI even though it passed locally. The CLI group
callback (phantom/cli/__init__.py) auto-runs `phantom setup` whenever no
.mcp.json holds a phantom entry, and it re-derived $HOME/cwd inline instead of
using the same resolver the writers use. Redirecting only the writers split the
pair: setup wrote into a fresh per-test sandbox while the check kept reading
cwd, so it never saw a configured install and re-ran full setup on every CLI
invocation, printing into output that tests parse as JSON.
This is invisible on a dev machine, where the repo's real .mcp.json satisfies
the check, and only appears where no .mcp.json exists -- i.e. CI. It surfaced
as 11 failures across tests/test_cli_analyze.py.
Route the first-run check through `setup._mcp_candidates()` so the check and the
writers can never disagree again, and seed the sandbox with a phantom entry so
auto-setup stays quiet under test.
The sandbox lives outside tmp_path: some tests point the resolvers at
tmp_path/".mcp.json" and assert on what the command writes there, and
test_no_predictable_tmp_left_behind asserts tmp_path's exact directory listing.
A per-test factory dir satisfies both.
Verified by simulating CI (no .mcp.json in cwd or $HOME, live tests deselected
as CI does since their fixtures aren't committed): 1016 passed, 44 skipped.
Normal local run with the config present: 1041 passed, 47 skipped, .mcp.json
byte-identical, and no ~/.mcp.json created.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
---------
Co-authored-by: Lee Saenz <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
0 commit comments