test_checklist_exit_precedence.py
python
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab
NXP-b DONE: independent BV-r2 pass + ISR (SD-17)
Human
minor
⚠ breaking
21 hours ago
| 1 | """Unit tests for checklist replace semantics and exit precedence (§K5.12).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from tests.support import FIXTURES, git_status_runner, run_cli, seed_freeze_repo, write_config |
| 8 | from cli.kit_root import kit_root |
| 9 | from tools.freeze_reviewer.checklist import builtin_checklist, load_checklist_file |
| 10 | from tools.freeze_reviewer.engine import resolve_exit_code |
| 11 | from tools.freeze_reviewer.types import ReviewResult |
| 12 | |
| 13 | |
| 14 | def test_builtin_checklist_ids() -> None: |
| 15 | ids = [item.id for item in builtin_checklist()] |
| 16 | assert ids == ["C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8"] |
| 17 | |
| 18 | |
| 19 | def test_checklist_file_replaces_builtin(tmp_path: Path) -> None: |
| 20 | items = load_checklist_file(FIXTURES / "checklist-replace.yaml") |
| 21 | assert [item.id for item in items] == ["X1"] |
| 22 | builtin_ids = {item.id for item in builtin_checklist()} |
| 23 | assert not any(item.id in builtin_ids for item in items) |
| 24 | |
| 25 | |
| 26 | def test_empty_checklist_config_error(tmp_path: Path) -> None: |
| 27 | path = tmp_path / "bad.yaml" |
| 28 | path.write_text("checks: []\n", encoding="utf-8") |
| 29 | import pytest |
| 30 | from adapters.errors import ConfigError |
| 31 | |
| 32 | with pytest.raises(ConfigError): |
| 33 | load_checklist_file(path) |
| 34 | |
| 35 | |
| 36 | def test_checklist_path_escape_exit_four(tmp_path: Path) -> None: |
| 37 | seed_freeze_repo(tmp_path) |
| 38 | code = run_cli( |
| 39 | ["review", "--freeze", "docs/FREEZE.md", "--checklist", "../outside.yaml"], |
| 40 | cwd=tmp_path, |
| 41 | runner=git_status_runner(), |
| 42 | kit=kit_root(), |
| 43 | ) |
| 44 | assert code == 4 |
| 45 | |
| 46 | |
| 47 | def test_exit_precedence() -> None: |
| 48 | assert resolve_exit_code(ReviewResult(), config_error=True) == 2 |
| 49 | assert resolve_exit_code(ReviewResult(refused=True), refused=True) == 4 |
| 50 | assert resolve_exit_code(ReviewResult(io_error=True)) == 5 |
| 51 | assert resolve_exit_code(ReviewResult(verdict="blocked", escalation="human")) == 8 |
| 52 | assert resolve_exit_code(ReviewResult(verdict="findings")) == 7 |
| 53 | assert resolve_exit_code(ReviewResult(verdict="pass")) == 0 |
File History
1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab
NXP-b DONE: independent BV-r2 pass + ISR (SD-17)
Human
minor
⚠
21 hours ago