From 293236490b567866f7468a5bee5d61b0dcf8086d Mon Sep 17 00:00:00 2001 From: chexit Date: Tue, 3 Nov 2026 10:49:21 +0300 Subject: [PATCH] test: freeze the exact budget fixture used by the runtime Derive synthetic terrain metadata from the fixture and copy the same bytes that were hashed before building. Co-authored-by: Codex --- tools/airdef.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/airdef.py b/tools/airdef.py index 3d7a26b..441554c 100644 --- a/tools/airdef.py +++ b/tools/airdef.py @@ -169,7 +169,7 @@ def test_budgets(): "schema": 1, "command": "test-budgets", "scenario": BUDGET_SCENARIO, - "scenario_render_world": "flat at y=64", + "scenario_render_world": None, "status": "failed", "exit_code": None, "scenario_counts": {"scripts": 1, "steps": None, "raid_requests": None, @@ -212,7 +212,11 @@ def test_budgets(): wasmtime = re.search(r'\[\[package\]\]\s*name = "wasmtime"\s*version = "([^"]+)"', lock_text) report["wasmtime_version"] = wasmtime.group(1) if wasmtime else None fixture = ROOT / "airdef-mod" / BUDGET_SCENARIO - fixture_text = fixture.read_text() + fixture_bytes = fixture.read_bytes() + fixture_text = fixture_bytes.decode("utf-8") + flat_heights = list(dict.fromkeys(re.findall(r"(?m)^render-ground-y\s*=\s*(-?\d+)\s*$", fixture_text))) + if flat_heights: + report["scenario_render_world"] = "flat at y=" + ",".join(flat_heights) counts = report["scenario_counts"] counts["steps"] = len(re.findall(r"(?m)^\[\[step\]\]$", fixture_text)) counts["air_defense_units"] = len(re.findall(r'(?m)^command = "airdef deploy [^"]+"', fixture_text)) @@ -221,7 +225,7 @@ def test_budgets(): counts["raid_units_requested"] = sum(map(int, requests)) for field in ("ticks", "frames"): counts[field] = sum(map(int, re.findall(rf"(?m)^{field}\s*=\s*(\d+)\s*$", fixture_text))) - report["scenario_sha256"] = hashlib.sha256(fixture.read_bytes()).hexdigest() + report["scenario_sha256"] = hashlib.sha256(fixture_bytes).hexdigest() mod() artifact = hmod() @@ -247,7 +251,7 @@ def test_budgets(): with tempfile.TemporaryDirectory(prefix="airdef-wasm-budget-") as temp: isolated = Path(temp) (isolated / "tests").mkdir() - shutil.copy2(fixture, isolated / "tests" / "wasm_budget.toml") + (isolated / "tests" / "wasm_budget.toml").write_bytes(fixture_bytes) command = [cargo(), "run", "--locked", "--manifest-path", FORK / "Cargo.toml", "-p", "cargo-horizon-mod", "--", "horizon-mod", "test", "--hmod", artifact, "budget"] print("+", " ".join(str(c) for c in command), flush=True)