Files
doslang-mirror/tools/tests/test_milestones_dosboxx.py
T
coolguyandClaude Opus 5 4ad3e3097b refactor: derive the milestone bounds from the registry
The highest supported milestone was spelled out in six places across four
files: range(1, 7) and default="m6" in test_cli.py, the same pair in
test_milestones_dosboxx.py, and through=6 in both registry.py and suite.py.
Registering M7 meant finding all six, and missing one failed silently.

Derive MAX_MILESTONE and MILESTONES from CASES instead, and move the mN
selector parser to registry.milestone_number so the pytest module stops
carrying its own copy. Adding cases for a new milestone is now enough for
ferro-test to accept --through/--only for it.

No behaviour change: MAX_MILESTONE evaluates to 6, ferro-test still advertises
{m1..m6} with default m6, and the case snapshot is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 22:11:36 +09:00

53 lines
1.7 KiB
Python

from __future__ import annotations
import os
import warnings
import pytest
from ferrolang_vm.dosboxx import SuiteRun, run_suite
from ferrolang_vm.registry import MAX_MILESTONE, all_cases, milestone_number
from ferrolang_vm.suite import Case
ONLY = os.environ.get("FERRO_TEST_ONLY")
CASES = all_cases(
through=milestone_number(os.environ.get("FERRO_TEST_THROUGH", f"m{MAX_MILESTONE}")),
only=milestone_number(ONLY) if ONLY else None,
)
@pytest.fixture(scope="session")
def suite_run() -> SuiteRun:
run = run_suite(
CASES,
keep=os.environ.get("FERRO_TEST_KEEP_FAILED") == "1",
show_dos=os.environ.get("FERRO_TEST_SHOW_DOS") == "1",
trace_dos=os.environ.get("FERRO_TEST_TRACE_DOS") == "1",
)
yield run
if os.environ.get("FERRO_TEST_DOS_LOG") == "1":
console = run.root / "CONSOLE.LOG"
if console.is_file():
print(console.read_text(encoding="utf-8", errors="replace"))
run.cleanup()
def test_compiler_build(suite_run: SuiteRun) -> None:
assert suite_run.result() == "PASS", suite_run.log()
@pytest.mark.parametrize("case", CASES, ids=lambda case: case.id)
def test_milestone_case(case: Case, suite_run: SuiteRun) -> None:
if suite_run.result() != "PASS":
pytest.skip("compiler build failed")
result = suite_run.result(case)
err = suite_run.err(case)
if result == "PASS" and err:
warning_lines = [line for line in err.splitlines() if "warning" in line.lower()]
if warning_lines:
warnings.warn("\n".join(warning_lines), stacklevel=1)
assert result == "PASS", (
f"DOS command: {case.command}\nExpected success: {case.expect_success}\n"
f"{suite_run.log(case)}\n{err}"
)