Files
rune/tests/test_tool_parity.py

46 lines
1.3 KiB
Python

"""test_tool_parity.py — TTY-repair tranche: canonical tool hash parity.
The installed MiMo tools MUST match the canonical sources
(same contract as test_hook_parity for hooks)."""
from __future__ import annotations
import hashlib
import os
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
TOOLS = ("bash.ts", "await-operation.ts")
def _canonical(name: str) -> Path:
return REPO / "config" / "mimo-tools" / name
def _installed(name: str) -> Path:
home = os.environ.get("RUNE_HOOK_TARGET_HOME", "/home/nick")
return Path(home) / ".mimocode" / "tools" / name
def _sha(p: Path) -> str:
return hashlib.sha256(p.read_bytes()).hexdigest()
def test_canonical_sources_exist():
for name in TOOLS:
assert _canonical(name).is_file(), f"missing canonical {name}"
def test_installed_matches_canonical():
for name in TOOLS:
inst = _installed(name)
assert inst.is_file(), f"tool missing at {inst}"
assert _sha(_canonical(name)) == _sha(inst), (
f"TOOL DRIFT: {name} canonical={_sha(_canonical(name))[:12]} "
f"installed={_sha(inst)[:12]} — run "
f"python3 scripts/install_mimo_tools.py to sync"
)
def test_installer_exists():
assert (REPO / "scripts/install_mimo_tools.py").is_file()