feat: run the CI suite as parallel processes

validate.yml and pr_checks.py run scripts/run_tests.py with four jobs,
the runner's cores: 24 minutes here for the suite that took about 40 in
one process. A failed module's tracebacks are printed in the summary, as
a runner keeps no log file. The two scripts added today follow the rules
the suite holds every script to (no abbreviated option, run_cli, every
option documented), and the two isolation tests drop the per-module
scratch variable to check the folder a module gets alone.
This commit is contained in:
Abdessamad Derraz committed 2026-11-12 15:36:46 +01:00
1 parent fb33ee58e1
commit abbfebff3e
11 files changed
+63 -27

No files matched your search

+6 -2
View File
@@ -86,7 +86,8 @@ def sources(paths: list[Path]) -> Iterator[tuple[str, bytes]]:
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.split("\n\n", 1)[0])
parser = argparse.ArgumentParser(allow_abbrev=False,
description=__doc__.split("\n\n", 1)[0])
parser.add_argument("paths", nargs="+", type=Path, help="files, folders or ZIPs to search")
parser.add_argument("--crc32", required=True, help="crc32 of the wanted file, in hex")
parser.add_argument("--size", required=True, type=int, help="size of the wanted file, in bytes")
@@ -125,4 +126,7 @@ def main() -> int:
if __name__ == "__main__":
sys.exit(main())
sys.path.insert(0, str(Path(__file__).resolve().parent))
from common import run_cli
run_cli(main)
+1 -1
View File
@@ -60,7 +60,7 @@ STEPS: tuple[Step, ...] = (
# filled it and every later command failed with ENOSPC.
Step("npm run build --prefix website", "the built site",
needs="npm", provider="Node 24", env={"NODE_DISABLE_COMPILE_CACHE": "1"}),
Step("python -m unittest discover -s tests -t .", "the suite",
Step("python scripts/run_tests.py --jobs 4", "the suite, one process per module",
env={"RETROBIOS_OFFLINE": "1"}),
Step("python3.8 -m unittest tests.test_install_tui", "the full screen on the installer's floor",
needs="python3.8", provider="a Python 3.8 with pyte",
+21 -6
View File
@@ -6,12 +6,12 @@ Usage:
python scripts/run_tests.py --jobs 1 # one at a time, as discover runs
python scripts/run_tests.py tests.test_install tests.test_e2e
`python -m unittest discover` runs 8,500 tests in one process: about 40
minutes here and 85 on the CI runner, and a module that left a variable or a
flag set changed the modules after it. Here each module gets a fresh process
unittest's discovery runs 8,500 tests in one process: about 40 minutes
here and 85 on the CI runner, and a module that left a variable or a flag
set changed the modules after it. Here each module gets a fresh process
and its own scratch folder (RETROBIOS_TEST_SCRATCH, read by tests/__init__),
the longest first so the last ones to start are short. Durations are kept in
tmp/test-durations.json, from the previous run; a module never timed is
tmp/test-durations.json, from the previous run, and a module never timed is
weighed by its size.
The host computes wrong and Python segfaults under load: a module killed by
@@ -41,6 +41,8 @@ DURATIONS = ROOT / "tmp" / "test-durations.json"
# third of the cores at once made them fail for no other reason.
DEFAULT_JOBS = max(1, min(6, (os.cpu_count() or 2) // 3))
# Lines of a failed module's tracebacks printed in the summary.
FAILURE_LINES = 200
_RAN = re.compile(r"^Ran (\d+) tests? in ([\d.]+)s$", re.M)
_COUNTS = re.compile(r"(failures|errors|skipped|expected failures|unexpected successes)=(\d+)")
@@ -117,7 +119,8 @@ def run_module(module: str, env: dict[str, str], logs: Path) -> Result:
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.split("\n\n", 1)[0])
parser = argparse.ArgumentParser(allow_abbrev=False,
description=__doc__.split("\n\n", 1)[0])
parser.add_argument("modules", nargs="*", help="modules to run (tests.test_x), all by default")
parser.add_argument("--jobs", "-j", type=int, default=DEFAULT_JOBS,
help=f"modules at once (default {DEFAULT_JOBS})")
@@ -169,9 +172,21 @@ def main() -> int:
print(f"FAILED {result.module}: {result.failures} failures, {result.errors} errors "
f"(code {result.code if result.crashed_then is None else result.crashed_then}), "
f"log {result.log.relative_to(ROOT) if result.log else '-'}")
# A CI runner shows the output and keeps no file: what failed, and
# why, is said here, the tracebacks unittest wrote, at most a page.
if result.log is not None:
text = result.log.read_text(encoding="utf-8", errors="replace")
start = text.find("\n" + "=" * 70)
shown = (text[start:] if start >= 0 else text).strip().splitlines()
for line in shown[:FAILURE_LINES]:
print(f" {line}")
if len(shown) > FAILURE_LINES:
print(f" ... {len(shown) - FAILURE_LINES} more lines in the log")
print("OK" if not failed else f"FAILED ({len(failed)} modules)")
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())
from common import run_cli
run_cli(main)