Files
horizon-airdef/tests/test_parity_runner.py
T
Ludovic Marie 6396e8c161 Run the vanilla harnesses in parallel, only when their inputs change
tools/parity.py traces each harness (its Python, Java oracle sources and
the Rust sources of the probes it runs, from Cargo's dep-info) and reruns
it only when one of those, the vanilla artifacts or the toolchains change.
Harnesses run in parallel within the available memory, and their probes
build without LTO and with 16 codegen units into .local/parity-target: a
one-line change rebuilds every horizon-world probe in 3 seconds instead of
122. The full suite takes about 20 minutes instead of an hour.

tools/gate.py is the check a branch passes before integration, and
tools/supervise.py manages the per-area worktrees: status, new worktrees,
saving unfinished work, and integrating a branch only when the gate passes.

Harnesses find probes through lab.cargo_target() instead of a hard-coded
target/, the save round-trip harness builds the binaries it launches, and
the mob AI harness now fails on divergences like every other harness
(--report-only keeps the old behaviour). Debug builds keep line tables
only, so worktrees stay small.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 15:05:36 +02:00

50 lines
2.6 KiB
Python

from pathlib import Path
import tempfile
import unittest
from unittest import mock
from tools import parity
class ParityRunnerTests(unittest.TestCase):
def test_dep_info_keeps_escaped_spaces(self):
with tempfile.TemporaryDirectory() as temp:
binary = Path(temp) / "probe"
Path(temp, "probe.d").write_text(f"{binary}: /a/x.rs /b/with\\ space.rs\n\n/a/x.rs:\n")
self.assertEqual(parity.dep_info(binary), ["/a/x.rs", "/b/with space.rs"])
def test_artifacts_follow_profile_and_stop_at_program_arguments(self):
self.assertEqual(parity.artifacts_of(["cargo", "build", "--release", "--example", "a", "--bin", "b"]),
[["example", "a", "release"], ["bin", "b", "release"]])
self.assertEqual(parity.artifacts_of(["cargo", "run", "--profile", "fast", "--example", "c", "--", "--example", "x"]),
[["example", "c", "fast"]])
self.assertEqual(parity.artifacts_of(["cargo", "build", "--example", "d"]), [["example", "d", "dev"]])
def test_java_sources_include_classes_pulled_from_the_sourcepath(self):
with tempfile.TemporaryDirectory() as temp:
sources, classes = Path(temp, "src"), Path(temp, "classes")
(sources / "p").mkdir(parents=True)
(classes / "p").mkdir(parents=True)
for name in ("Oracle", "Helper"):
(sources / "p" / f"{name}.java").write_text("")
for name in ("Oracle", "Helper$Inner"):
(classes / "p" / f"{name}.class").write_bytes(b"")
found = parity.java_sources(["javac", "-sourcepath", str(sources), "-d", str(classes), str(sources / "p/Oracle.java")])
self.assertEqual(sorted(Path(path).name for path in found), ["Helper.java", "Oracle.java", "Oracle.java"])
def test_a_pass_goes_stale_when_a_dependency_changes(self):
with tempfile.TemporaryDirectory() as temp, mock.patch.object(parity, "ROOT", Path(temp)):
source = Path(temp, "a.rs")
source.write_text("one")
state = {"harnesses": {"x": {"status": "pass", "dependencies": ["a.rs"]}}, "hashes": {}}
hasher = parity.Hasher(state["hashes"])
state["harnesses"]["x"]["key"] = parity.key(state["harnesses"]["x"], hasher, "env")
self.assertFalse(parity.stale("x", state, hasher, "env"))
self.assertTrue(parity.stale("x", state, hasher, "other toolchain"))
source.write_text("two!")
self.assertTrue(parity.stale("x", state, hasher, "env"))
if __name__ == "__main__":
unittest.main()