Files
rune/tests/test_paths_central.py
T
Nick 299ae4eff9 fix(paths): #41 CLOSED — centralized environment paths + twin verdict (contract BUILDER-2026-10-08T11:04:31Z-55ae38)
- paths.py: ONE live implementation (repo_root from file location —
  THREE levels, not two; crate_dir, deploy_root, rune_home,
  harness_scripts, wait_resume_dir — all with env overrides)
- 13 hardcoded literals collapsed across 12 files
- the spelling twins are DISTINCT modules (behavior = scoped
  corrections; behaviour_ledger = versioned validation ledger) — the
  issue premise was wrong for this pair; pinned by test
- test_paths_central.py: no-hardcoded-literals gate (fails the build
  on any new literal) + twin-distinctness pin

3/3 green. #41 closed with evidence.
2026-10-08 12:20:18 +01:00

50 lines
1.9 KiB
Python

"""test_paths_central.py — #41: one live implementation per path.
No hardcoded /mnt|/home literals outside paths.py (env overrides and
defaults are paths.py's job); the centralized dirs resolve to real
directories; the spelling twins are distinct modules (not duplicates)."""
import re
import sys
from pathlib import Path
import pytest
REPO = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO / "src"))
sys.path.insert(0, str(REPO / "src" / "rune"))
from rune import paths # noqa: E402
class TestNoHardcodedLiterals:
def test_no_hardcoded_workdrive_outside_paths(self):
offenders = []
for f in (REPO / "src" / "rune").glob("*.py"):
if f.name == "paths.py":
continue
for i, line in enumerate(f.read_text().splitlines(), 1):
if re.search(r'''=\s*["']/mnt/|["']/home/''', line):
if "expanduser" in line or "environ" in line or "memory_env" in line:
continue
offenders.append(f"{f.name}:{i}: {line.strip()[:70]}")
assert not offenders, f"hardcoded paths outside paths.py:\n" + "\n".join(offenders)
def test_central_dirs_resolve(self):
assert Path(paths.repo_root()).is_dir()
assert Path(paths.crate_dir("evidence_provenance")).is_dir()
assert paths.deploy_root().startswith("/")
assert paths.rune_home().startswith("/")
class TestTwinsAreDistinct:
def test_behavior_vs_behaviour_ledger(self):
"""The US/UK twins are DIFFERENT modules (not duplicates): behavior
= scoped corrections + habits; behaviour_ledger = versioned
validation ledger. #41's premise was wrong for this pair."""
from rune import behavior as bh_us
from rune import behaviour_ledger as bl_uk
assert hasattr(bh_us, "add_correction") or hasattr(bh_us, "reinforce")
assert hasattr(bl_uk, "BehaviourLedger")
assert bh_us.__name__ != bl_uk.__name__