These grew one bug at a time in a scratch directory and were about to be thrown away, having caught four real regressions between them. Move them in as they are -- plain scripts, stdlib only, no test dependency -- behind a shared harness and `python3 tests/run.py`. The harness exists mostly for its guard. A suite testing the purge path once sandboxed LLMHOST_CONFIG but not LLMHOST_HOME and deleted a live install's data directory; BIN_DIR and SHIM have no env override at all, coming straight off Path.home(). So the harness repoints those into the sandbox and then asserts that every path llmhost could write or delete is inside it, aborting the run if not -- verified by pointing it at a real path and watching it refuse. The model plan the opencode suite needs is now a fixture rather than a file read out of someone's home directory; it carries no key (the key lives in its own file) and its machine-specific fields are pinned. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
45 lines
1.6 KiB
Python
Executable file
45 lines
1.6 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""Run every suite in tests/ and summarise. Exits nonzero if any failed.
|
|
|
|
python3 tests/run.py all suites
|
|
python3 tests/run.py proxy just the ones whose name contains "proxy"
|
|
"""
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
|
|
|
|
def main(argv):
|
|
picks = argv[1:]
|
|
suites = sorted(p for p in HERE.glob("test_*.py")
|
|
if not picks or any(a in p.stem for a in picks))
|
|
if not suites:
|
|
print("no suites matched", picks)
|
|
return 1
|
|
width = max(len(p.stem) for p in suites)
|
|
results, total = [], 0
|
|
for p in suites:
|
|
r = subprocess.run([sys.executable, str(p)], capture_output=True, text=True)
|
|
tail = [l for l in r.stdout.splitlines() if l.strip()]
|
|
summary = tail[-1] if tail else "(no output)"
|
|
ok = r.returncode == 0
|
|
count = 0
|
|
for word in summary.replace("(", " ").replace(")", " ").split():
|
|
if word.isdigit():
|
|
count = int(word)
|
|
break
|
|
total += count if ok else 0
|
|
print(f" {p.stem:<{width}} {'PASS' if ok else 'FAIL'} {summary}")
|
|
if not ok:
|
|
print("\n".join(" " + l for l in r.stdout.splitlines() if "FAIL" in l))
|
|
if r.stderr.strip():
|
|
print(" stderr: " + r.stderr.strip().splitlines()[-1])
|
|
results.append(ok)
|
|
print(f"\n{sum(results)}/{len(results)} suites passed, {total} checks")
|
|
return 0 if all(results) else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv))
|