8fb6b65b01
- pre_work_check.py: prefer repo .venv Python >=3.11, strict JYOTISH_PRE_WORK_PYTHON override, fail closed - tests/test_pre_work_check.py: regression coverage for venv preference / system 3.9 / strict override - globals.css: transient :active pressed feedback for entrypoint cards, hover only under (hover: hover) - consultation-entrypoint.test.ts: sticky-hover regression test - BUG_HISTORY.md: BUG-139 / BUG-140 records - pre_work_error_ledger.md: ERR-078 resolved entry
95 lines
3.5 KiB
Python
95 lines
3.5 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from scripts.pre_work_check import (
|
|
DEFAULT_COMMAND_TIMEOUT_SECONDS,
|
|
DEFAULT_FRAGMENT_TIMEOUT_SECONDS,
|
|
EXTERNAL_ENGINE_DIAGNOSTIC_TARGET,
|
|
FOCUSED_TEST_TARGETS,
|
|
PRE_WORK_DOCS,
|
|
PYTHON_OVERRIDE_ENV,
|
|
classify_status,
|
|
python_candidates,
|
|
select_python,
|
|
)
|
|
|
|
|
|
def test_classify_status_keeps_remote_blocked_distinct_from_failure() -> None:
|
|
assert classify_status(True, True, True, "verified") == "pass"
|
|
assert classify_status(True, True, True, "blocked") == "pass_with_remote_blocked"
|
|
assert classify_status(True, True, False, "verified") == "fail"
|
|
assert classify_status(True, True, True, "verified", python_ok=False) == "fail"
|
|
|
|
|
|
def test_pre_work_check_prefers_project_venv_over_launching_python(tmp_path: Path) -> None:
|
|
candidates = python_candidates(root=tmp_path, environ={}, current_executable="/usr/bin/python3")
|
|
|
|
assert candidates[0] == str(tmp_path / ".venv" / "bin" / "python")
|
|
assert candidates[1] == str(tmp_path / ".venv" / "Scripts" / "python.exe")
|
|
assert candidates[2] == "/usr/bin/python3"
|
|
|
|
|
|
def test_pre_work_check_python_override_is_strict() -> None:
|
|
candidates = python_candidates(
|
|
environ={PYTHON_OVERRIDE_ENV: "/opt/project-python"},
|
|
current_executable="/usr/bin/python3",
|
|
)
|
|
|
|
assert candidates == ["/opt/project-python"]
|
|
|
|
|
|
def test_pre_work_check_skips_incompatible_launcher_and_selects_venv() -> None:
|
|
results = {
|
|
"/usr/bin/python3": {
|
|
"candidate": "/usr/bin/python3",
|
|
"ok": False,
|
|
"version": "3.9.6",
|
|
"pytest_available": False,
|
|
"error": "Python 3.9 is below required 3.11; pytest is not installed",
|
|
},
|
|
".venv/bin/python": {
|
|
"candidate": ".venv/bin/python",
|
|
"ok": True,
|
|
"version": "3.11.15",
|
|
"pytest_available": True,
|
|
"error": "",
|
|
},
|
|
}
|
|
|
|
selected = select_python(
|
|
["/usr/bin/python3", ".venv/bin/python"],
|
|
probe=lambda candidate: results[candidate],
|
|
)
|
|
|
|
assert selected["ok"] is True
|
|
assert selected["executable"] == ".venv/bin/python"
|
|
assert [attempt["candidate"] for attempt in selected["attempts"]] == [
|
|
"/usr/bin/python3",
|
|
".venv/bin/python",
|
|
]
|
|
|
|
|
|
def test_pre_work_check_runs_governance_test_set() -> None:
|
|
assert "tests/test_runtime_import_boundaries.py" in FOCUSED_TEST_TARGETS
|
|
assert "tests/test_project_fragment_governance.py" in FOCUSED_TEST_TARGETS
|
|
assert "tests/test_preflight_fragment_scan.py" in FOCUSED_TEST_TARGETS
|
|
assert "tests/test_remote_repo_visibility_check.py" in FOCUSED_TEST_TARGETS
|
|
assert "tests/test_pre_work_check.py" in FOCUSED_TEST_TARGETS
|
|
|
|
|
|
def test_pre_work_check_requires_error_ledger_and_fragment_sweeps() -> None:
|
|
assert "docs/research/pre_work_error_ledger.md" in PRE_WORK_DOCS
|
|
assert "docs/research/whole_machine_fragment_sweep_2026_07_05.md" in PRE_WORK_DOCS
|
|
assert "docs/research/whole_machine_fragment_sweep_2026_07_14.md" in PRE_WORK_DOCS
|
|
assert "docs/research/whole_machine_fragment_sweep_round25_2026_06_25.md" in PRE_WORK_DOCS
|
|
|
|
|
|
def test_pre_work_check_includes_external_engine_diagnostics() -> None:
|
|
assert EXTERNAL_ENGINE_DIAGNOSTIC_TARGET == "scripts/diagnose_external_engine_adapters.py"
|
|
|
|
|
|
def test_pre_work_check_child_command_timeout_stays_short() -> None:
|
|
assert DEFAULT_COMMAND_TIMEOUT_SECONDS <= 45
|
|
assert DEFAULT_FRAGMENT_TIMEOUT_SECONDS >= DEFAULT_COMMAND_TIMEOUT_SECONDS
|