init: company-haness 설계
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The suite timeout must reap descendants, not only the direct test process."""
|
||||
import importlib.util
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
RUNNER = os.path.join(ROOT, ".claude", "tests", "run_all.py")
|
||||
spec = importlib.util.spec_from_file_location("run_all_under_test", RUNNER)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
module.SUITE_TIMEOUT = 1
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="runner-pg-") as directory:
|
||||
pid_path = os.path.join(directory, "child.pid")
|
||||
code = (
|
||||
"import subprocess,time,pathlib; "
|
||||
f"p=subprocess.Popen(['{sys.executable}','-c','import time; time.sleep(30)']); "
|
||||
f"pathlib.Path({pid_path!r}).write_text(str(p.pid)); "
|
||||
"time.sleep(30)"
|
||||
)
|
||||
ok = module.run([sys.executable, "-c", code], "process-group-timeout-fixture")
|
||||
if ok or not os.path.exists(pid_path):
|
||||
print("FAIL timeout fixture did not run as expected")
|
||||
raise SystemExit(1)
|
||||
child_pid = int(open(pid_path, encoding="utf-8").read())
|
||||
alive = True
|
||||
for _ in range(20):
|
||||
try:
|
||||
os.kill(child_pid, 0)
|
||||
except ProcessLookupError:
|
||||
alive = False
|
||||
break
|
||||
time.sleep(0.05)
|
||||
if alive:
|
||||
subprocess.run(["kill", "-9", str(child_pid)], check=False)
|
||||
print("FAIL descendant survived suite timeout")
|
||||
raise SystemExit(1)
|
||||
|
||||
print("1 passed, 0 failed")
|
||||
Reference in New Issue
Block a user