Files
sisi/tests/run_parallel.py
T
swaitsandClaude Fable 5.2 2fc1fe9c2d
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
sisi 0.1.0: a shared rulebook and verification tool for AI coding agents
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and
shared lessons, time-to-delivery measurement, a library of 140 verification
techniques and 20 recipes, personal data kept outside the clone, and
releases with rollback. Standard library only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:29:02 -07:00

64 lines
2.1 KiB
Python

"""Run every test module in its own process, several at a time.
The suite is the fast check in this project's contract, so it runs at the end
of every agent turn and must finish well inside 60 seconds even on a busy
machine. Each module already isolates itself (temporary home, state and data
folders), so modules are safe to run side by side.
Usage: python3 tests/run_parallel.py [-j N]
Exit status is 0 only if every module passes. Output of a failing module is
printed in full; passing modules print one line.
"""
import concurrent.futures
import os
import subprocess
import sys
import time
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)
def run(module):
start = time.time()
proc = subprocess.run(
[sys.executable, "-W", "ignore::ResourceWarning", "-m", "unittest", module],
cwd=HERE, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, text=True,
)
return module, proc.returncode, proc.stdout, time.time() - start
def main(argv):
jobs = os.cpu_count() or 4
if "-j" in argv:
jobs = int(argv[argv.index("-j") + 1])
modules = sorted(f[:-3] for f in os.listdir(HERE)
if f.startswith("test_") and f.endswith(".py"))
if not modules:
print("no test modules found")
return 1
failed = []
total = 0
start = time.time()
with concurrent.futures.ThreadPoolExecutor(max_workers=jobs) as pool:
for module, code, out, secs in pool.map(run, modules):
ran = [l for l in out.splitlines() if l.startswith("Ran ")]
count = int(ran[-1].split()[1]) if ran else 0
total += count
if code != 0 or not ran:
failed.append(module)
print("FAILED %s (%.1fs)\n%s" % (module, secs, out))
else:
print("ok %-28s %4d tests %6.1fs" % (module, count, secs))
print("\nRan %d tests in %d modules in %.1fs" % (total, len(modules), time.time() - start))
if failed:
print("FAILED: " + ", ".join(failed))
return 1
print("OK")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))