Private
Public Access
fix(paths): route ALL path getters through config.toml [paths] overrides (FR2 v2)
This commit is contained in:
+27
-24
@@ -376,12 +376,17 @@ def _enforce_test_sandbox() -> Generator[None, None, None]:
|
||||
def isolate_workspace(monkeypatch) -> Generator[None, None, None]:
|
||||
"""
|
||||
Autouse fixture to isolate tests from the active user workspace.
|
||||
Workspace lives under tests/artifacts/_isolation_workspace_<RUN_ID>/ per
|
||||
conductor/code_styleguides/workspace_paths.md (replaces the historical
|
||||
tmp_path_factory.mktemp pattern). Writes placeholder TOMLs so src/ code
|
||||
that reads these files at startup does not crash.
|
||||
[C: tests/conftest.py:_ISOLATION_WORKSPACE, src/paths.py:set_config_override]
|
||||
Writes config_overrides.toml with a [paths] section that overrides every
|
||||
path getter in src/paths.py to point inside this test's workspace
|
||||
(tests/artifacts/_isolation_workspace_<RUN_ID>/). Also writes placeholder
|
||||
TOML files for the redirected paths. NO SLOP_* env vars are set;
|
||||
src/paths.py reads the overrides from config.toml [paths] (with env var
|
||||
as fallback if needed).
|
||||
[C: tests/conftest.py:_ISOLATION_WORKSPACE, src/paths.py:_resolve_path]
|
||||
"""
|
||||
from src import paths as _paths
|
||||
_paths.reset_resolved()
|
||||
|
||||
test_workspace = _ISOLATION_WORKSPACE
|
||||
|
||||
config_path = test_workspace / "config_overrides.toml"
|
||||
@@ -391,24 +396,26 @@ def isolate_workspace(monkeypatch) -> Generator[None, None, None]:
|
||||
tomli_w.dump({
|
||||
'ai': {'provider': 'gemini', 'model': 'gemini-2.5-flash-lite'},
|
||||
'projects': {'paths': [], 'active': ''},
|
||||
'gui': {'show_windows': {}}
|
||||
'gui': {'show_windows': {}},
|
||||
'paths': {
|
||||
'presets': str(test_workspace / "presets.toml"),
|
||||
'tool_presets': str(test_workspace / "tool_presets.toml"),
|
||||
'personas': str(test_workspace / "personas.toml"),
|
||||
'themes': str(test_workspace / "themes"),
|
||||
'workspace_profiles': str(test_workspace / "workspace_profiles.toml"),
|
||||
'credentials': str(test_workspace / "credentials.toml"),
|
||||
'logs_dir': str(test_workspace / "logs"),
|
||||
'scripts_dir': str(test_workspace / "scripts"),
|
||||
},
|
||||
}, f)
|
||||
|
||||
(test_workspace / "themes").mkdir(exist_ok=True)
|
||||
for name in (
|
||||
"presets.toml", "tool_presets.toml", "personas.toml",
|
||||
"workspace_profiles.toml", "credentials.toml", "mcp_env.toml",
|
||||
):
|
||||
(test_workspace / name).touch()
|
||||
|
||||
monkeypatch.setenv("SLOP_GLOBAL_PRESETS", str(test_workspace / "presets.toml"))
|
||||
monkeypatch.setenv("SLOP_GLOBAL_TOOL_PRESETS", str(test_workspace / "tool_presets.toml"))
|
||||
monkeypatch.setenv("SLOP_GLOBAL_PERSONAS", str(test_workspace / "personas.toml"))
|
||||
monkeypatch.setenv("SLOP_GLOBAL_WORKSPACE_PROFILES", str(test_workspace / "workspace_profiles.toml"))
|
||||
monkeypatch.setenv("SLOP_CREDENTIALS", str(test_workspace / "credentials.toml"))
|
||||
monkeypatch.setenv("SLOP_MCP_ENV", str(test_workspace / "mcp_env.toml"))
|
||||
monkeypatch.setenv("SLOP_LOGS_DIR", str(test_workspace / "logs"))
|
||||
monkeypatch.setenv("SLOP_SCRIPTS_DIR", str(test_workspace / "scripts"))
|
||||
|
||||
yield
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -739,17 +746,13 @@ def live_gui(request) -> Generator["_LiveGuiHandle", None, None]:
|
||||
log_file_name = Path(gui_script).name.replace('.', '_')
|
||||
log_file = open(f"tests/logs/{log_file_name}_test.log", "w", encoding="utf-8")
|
||||
|
||||
# Use environment variable to point to temp config if App supports it,
|
||||
# or just run from that CWD.
|
||||
# The sloppy.py subprocess reads path overrides from --config (which
|
||||
# points at a config_overrides.toml inside temp_workspace that has the
|
||||
# [paths] table). No SLOP_* env vars needed; sloppy.py itself reads
|
||||
# paths from the config file.
|
||||
env = os.environ.copy()
|
||||
env["PYTHONPATH"] = str(project_root.absolute())
|
||||
if cred_file.exists():
|
||||
env["SLOP_CREDENTIALS"] = str(cred_file.absolute())
|
||||
if mcp_file.exists():
|
||||
env["SLOP_MCP_ENV"] = str(mcp_file.absolute())
|
||||
env["SLOP_GLOBAL_PRESETS"] = str((temp_workspace / "presets.toml").absolute())
|
||||
env["SLOP_GLOBAL_TOOL_PRESETS"] = str((temp_workspace / "tool_presets.toml").absolute())
|
||||
|
||||
|
||||
gui_args = ["uv", "run", "python", "-u", gui_script, "--enable-test-hooks"]
|
||||
if config_file.exists():
|
||||
gui_args.append(f"--config={config_file.absolute()}")
|
||||
|
||||
Reference in New Issue
Block a user