chore: restore original directory structure (project under code-review-graph-main/)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Shared test fixtures.
|
||||
|
||||
Keeps code-review-graph's own per-user state out of the developer's real
|
||||
home directory. Scoped deliberately: the editor-integration installers in
|
||||
``skills.py`` write to other user-level locations (``~/.codex``,
|
||||
``~/.cursor``, ``~/.config/opencode``) that are outside CRG state and are
|
||||
not covered here — those tests patch ``Path.home()`` themselves.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def isolated_crg_home(tmp_path_factory, monkeypatch):
|
||||
"""Redirect the per-user state directory into a temporary directory.
|
||||
|
||||
``~/.code-review-graph`` holds ``registry.json``, ``watch.toml``,
|
||||
``daemon.pid``, ``daemon-state.json`` and ``logs/``. Two paths reached
|
||||
the real one:
|
||||
|
||||
* ``Registry()`` defaults there, and ``incremental.get_data_dir()``
|
||||
constructs one internally — so any test touching data-dir resolution
|
||||
both read and wrote the registry of whoever ran the suite. That put
|
||||
pytest tmp paths into a developer's home directory, and made those
|
||||
tests depend on machine state: a developer with a registered repo
|
||||
could get different results from one without.
|
||||
* ``daemon`` built its config/PID/state paths from ``Path.home()``.
|
||||
|
||||
Autouse and unconditional: an opt-in fixture would silently stop
|
||||
protecting a test the day someone forgets to request it.
|
||||
"""
|
||||
home = tmp_path_factory.mktemp("crg-home")
|
||||
monkeypatch.setenv("CRG_HOME", str(home))
|
||||
return home
|
||||
Reference in New Issue
Block a user