Files
stack/agents/filbert/work/queue-90/r1/gate.py
T

22 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os, subprocess, pathlib, datetime, json
root=pathlib.Path.home()/"filbert-scratch/r90-review/wt"
out=root.parent/"gate"
out.mkdir(exist_ok=True)
env=dict(os.environ, TMPDIR=str(pathlib.Path.home()/"filbert-scratch/tmp"), DOCKER_HOST="unix:///nonexistent.sock")
rows=[]
for package in ["tasks","bus","harness","webui","cli","business","seat","control-board"]:
cwd=root/"packages"/package
files=["tests/"] if package in ["seat","webui"] else [str(x.relative_to(cwd)) for x in sorted((cwd/"tests").glob("*.test.mjs"))]
with (out/("node-"+package+".log")).open("w") as f:
r=subprocess.run(["node","--test",*files],cwd=cwd,env=env,stdout=f,stderr=subprocess.STDOUT)
log=(out/("node-"+package+".log")).read_text()
stats=[s for s in log.splitlines() if s.startswith(("# tests ","# pass ","# fail ","ℹ tests ","ℹ pass ","ℹ fail "))]
row={"suite":package,"rc":r.returncode,"stats":stats}; rows.append(row);print(json.dumps(row),flush=True)
for script in sorted((root/"scripts").glob("test-*.sh")):
with (out/(script.stem+".log")).open("w") as f:
r=subprocess.run(["bash",str(script)],cwd=root,env=env,stdout=f,stderr=subprocess.STDOUT)
log=(out/(script.stem+".log")).read_text()
row={"suite":script.stem,"rc":r.returncode,"last":log.splitlines()[-1:]};rows.append(row);print(json.dumps(row),flush=True)
(out/"summary.json").write_text(json.dumps(rows,indent=2)+"\n")
raise SystemExit(any(x["rc"] for x in rows))