83 lines
2.7 KiB
Python
83 lines
2.7 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pathlib import Path
|
||
|
|
import sys
|
||
|
|
|
||
|
|
|
||
|
|
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||
|
|
SCRIPT_DIR = PROJECT_ROOT / "scripts"
|
||
|
|
README_PATH = PROJECT_ROOT / "README.md"
|
||
|
|
|
||
|
|
if str(SCRIPT_DIR) not in sys.path:
|
||
|
|
sys.path.insert(0, str(SCRIPT_DIR))
|
||
|
|
|
||
|
|
from verify_first_level_edit_suites import QUICK_COMMANDS, STAGES # noqa: E402
|
||
|
|
|
||
|
|
|
||
|
|
def _assert(condition: bool, message: str) -> None:
|
||
|
|
if not condition:
|
||
|
|
raise AssertionError(message)
|
||
|
|
|
||
|
|
|
||
|
|
def _command_path(script_name: str) -> Path:
|
||
|
|
script_path = SCRIPT_DIR / script_name
|
||
|
|
if script_path.exists():
|
||
|
|
return script_path
|
||
|
|
return PROJECT_ROOT / script_name
|
||
|
|
|
||
|
|
|
||
|
|
def _commands() -> tuple[tuple[str, str, tuple[str, ...]], ...]:
|
||
|
|
collected: list[tuple[str, str, tuple[str, ...]]] = []
|
||
|
|
for stage_name, _stage_label, cases in STAGES:
|
||
|
|
for _label, command in cases:
|
||
|
|
collected.append((stage_name, command[0], command[1:]))
|
||
|
|
for _label, command in QUICK_COMMANDS:
|
||
|
|
collected.append(("quick", command[0], command[1:]))
|
||
|
|
return tuple(collected)
|
||
|
|
|
||
|
|
|
||
|
|
def _verify_script_inventory() -> None:
|
||
|
|
for stage_name, script_name, _args in _commands():
|
||
|
|
path = _command_path(script_name)
|
||
|
|
_assert(path.exists(), f"{stage_name} command target is missing: {script_name}")
|
||
|
|
|
||
|
|
|
||
|
|
def _verify_readme_mentions(readme: str) -> None:
|
||
|
|
required_fragments = (
|
||
|
|
"当前整体验证基线",
|
||
|
|
"不等于 CAD 级完成",
|
||
|
|
"Face 阶段的当前验收口径",
|
||
|
|
"verify_first_level_edit_suites.py --quick",
|
||
|
|
"verify_first_level_edit_suites.py --stage face",
|
||
|
|
"verify_first_level_edit_suites.py --stage hole-slot",
|
||
|
|
"verify_first_level_edit_suites.py --stage edge",
|
||
|
|
"verify_first_level_edit_suites.py --stage boss --stage round-chamfer --stage shell --stage analytic",
|
||
|
|
"一级编辑总验证入口",
|
||
|
|
"真实 STEP 失败项",
|
||
|
|
)
|
||
|
|
for fragment in required_fragments:
|
||
|
|
_assert(fragment in readme, f"README missing first-level acceptance fragment: {fragment}")
|
||
|
|
|
||
|
|
for stage_name, _stage_label, _cases in STAGES:
|
||
|
|
_assert(
|
||
|
|
f"--stage {stage_name}" in readme or stage_name in {"round-chamfer", "shell", "analytic"},
|
||
|
|
f"README should mention how to run stage {stage_name}",
|
||
|
|
)
|
||
|
|
|
||
|
|
for stage_name, script_name, _args in _commands():
|
||
|
|
if script_name == "main.py":
|
||
|
|
continue
|
||
|
|
_assert(script_name in readme, f"README should mention {stage_name} command script {script_name}")
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> int:
|
||
|
|
readme = README_PATH.read_text(encoding="utf-8")
|
||
|
|
_verify_script_inventory()
|
||
|
|
_verify_readme_mentions(readme)
|
||
|
|
print("first-level acceptance docs ok")
|
||
|
|
return 0
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
raise SystemExit(main())
|