"""Automated smoke test for Hell Tower 6-floor run-through.""" import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] POKER_ASM = ROOT / "poker.asm" def main(): print("[1/4] Preparing test harness in poker.asm...") code = POKER_ASM.read_text(encoding="cp1251") target = "\nIFDEF CASINO_ACTION_TEST\n" if "CASINO_ACTION_TEST equ 1\n" not in code: code = code.replace(target, "\nCASINO_ACTION_TEST equ 1\nIFDEF CASINO_ACTION_TEST\n") POKER_ASM.write_text(code, encoding="cp1251") try: print("[2/4] Building poker.exe with test harness...") build_res = subprocess.run(["cmd.exe", "/c", "build.bat"], cwd=ROOT, capture_output=True, text=True) if build_res.returncode != 0: print("[FAIL] Build failed:", build_res.stdout, build_res.stderr) return 1 print("[3/4] Running Hell Tower 6-floor run-through...") run_res = subprocess.run([str(ROOT / "poker.exe")], cwd=ROOT, capture_output=True, timeout=15) print(f"Hell Tower test completed with exit code: {run_res.returncode}") if run_res.returncode != 0: print(f"[FAIL] Hell Tower run-through failed with code {run_res.returncode}") return run_res.returncode print("[SUCCESS] All 6 floors of Hell Tower completed without errors or crashes!") finally: print("[4/4] Restoring normal poker.asm and rebuilding...") restored = POKER_ASM.read_text(encoding="cp1251") if "CASINO_ACTION_TEST equ 1\n" in restored: restored = restored.replace("CASINO_ACTION_TEST equ 1\n", "") POKER_ASM.write_text(restored, encoding="cp1251") subprocess.run(["cmd.exe", "/c", "build.bat"], cwd=ROOT, capture_output=True, text=True) print("[OK] Production poker.exe rebuilt cleanly.") return 0 if __name__ == "__main__": sys.exit(main())