- 21.2B: resolve_cwd returns repo_identity (git:<path> stripped) not scaffold_location; worktree override; unknown project raises; no repo → refuse; 8 held-outs incl. old-bug reproduction. - 21.2C: wait_guard covers time.sleep(N) (inline + heredoc), polling loops (while/until + status on full command), repeated delay+status; 7 new held-outs; legitimate cases still pass. - 21.2D: canonical hook source at config/mimo-hooks/event-wait-guard.ts; scripts/install_mimo_hook.py verifies hash; drift test detects canonical↔installed divergence. - 21.2G: programme_gates.py — mandatory gates end in PASS/BLOCKED/ WAIVED_BY_USER only; GateDemotionError prevents mandatory→optional demotion; 6 held-outs.
27 lines
966 B
Python
27 lines
966 B
Python
"""test_hook_drift.py — T21.2 §21.2D: canonical hook source/install/drift."""
|
|
from __future__ import annotations
|
|
import sys
|
|
from pathlib import Path
|
|
REPO = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(REPO / "src"))
|
|
from pathlib import Path as P
|
|
|
|
|
|
def test_212d1_canonical_source_exists():
|
|
assert (REPO / "config/mimo-hooks/event-wait-guard.ts").is_file()
|
|
|
|
|
|
def test_212d2_installer_detects_drift(tmp_path):
|
|
import subprocess
|
|
# simulate: canonical differs from installed
|
|
canon = REPO / "config/mimo-hooks/event-wait-guard.ts"
|
|
installed = Path.home() / ".mimocode" / "hooks" / "event-wait-guard.ts"
|
|
if installed.is_file():
|
|
assert canon.read_bytes() == installed.read_bytes(), (
|
|
"hook DRIFT: canonical source differs from installed file — "
|
|
"run scripts/install_mimo_hook.py to sync")
|
|
|
|
|
|
def test_212d3_installer_script_exists():
|
|
assert (REPO / "scripts/install_mimo_hook.py").is_file()
|