"""Run the app's test scripts one after another and summarise (2026-10-16). usage: python run_all_tests.py [name ...] fast = tests without Rhino; rhino = tests with real Rhino runs (one at a time, each can take several minutes). Each test's output goes to 검증/_rerun__.log; the summary (verdict, exit code, seconds, FAIL lines) to 검증/_rerun_summary__.json. A test passes when its exit code is 0 and no line starts with 'FAIL'. """ import json import subprocess import sys import time from pathlib import Path APP = Path(__file__).resolve().parents[1] FAST = ["test_consistency", "test_geomread", "test_batch_notice", "test_review", "test_open19", "test_rampa", "test_saejae", "test_okseong", "test_confirm_required", "test_templates", "test_recommend", "test_recommend_web", "test_ulsan_p2", "test_variability", "test_autocheck", "test_anchors", "test_delete_pier", "test_store_concurrency", "test_rampa_web"] RHINO = ["test_web_batch", "test_pier_batch_button", "test_individual_after_batch", "test_web", "test_web_ulsan", "test_web_ulsan_full", "test_ulsan_e2e"] TIMEOUT = {"test_web": 2400, "test_web_ulsan": 1500, "test_web_ulsan_full": 2400, "test_ulsan_e2e": 3000, "test_web_batch": 2400} def run(name, stamp): log = APP / "검증" / f"_rerun_{name}_{stamp}.log" t0 = time.time() try: r = subprocess.run([sys.executable, "-u", str(APP / "tools" / f"{name}.py")], cwd=str(APP), capture_output=True, timeout=TIMEOUT.get(name, 900), env={**__import__("os").environ, "PYTHONIOENCODING": "utf-8"}) out, code = r.stdout.decode("utf-8", "replace") + r.stderr.decode("utf-8", "replace"), r.returncode except subprocess.TimeoutExpired as e: out, code = (e.stdout or b"").decode("utf-8", "replace") + "\nTIMEOUT", -9 log.write_text(out, encoding="utf-8") fails = [ln[:240] for ln in out.splitlines() if ln.startswith("FAIL")] return {"test": name, "ok": code == 0 and not fails, "exit": code, "secs": round(time.time() - t0), "fails": fails[:8], "tail": out.strip().splitlines()[-1][:200] if out.strip() else ""} if __name__ == "__main__": sys.stdout.reconfigure(encoding="utf-8", errors="replace") group = sys.argv[1] names = sys.argv[2:] or (FAST if group == "fast" else RHINO if group == "rhino" else FAST + RHINO) stamp = time.strftime("%Y%m%d") res = [] for n in names: r = run(n, stamp) res.append(r) print(("PASS" if r["ok"] else "FAIL"), n, r["secs"], "s", r["tail"], flush=True) (APP / "검증" / f"_rerun_summary_{group}_{stamp}.json").write_text(json.dumps(res, ensure_ascii=False, indent=1), encoding="utf-8") print("DONE", sum(r["ok"] for r in res), "/", len(res))