Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Tools tests: the vehicle sources verifier fails on a changed byte; committed Steam icons match the script (Fixes #2737) (#2750)

Beri84fdff95f223
diff --git a/tools/tests/test_steam_achievement_icons.py b/tools/tests/test_steam_achievement_icons.py
index 5dde92cf6..2fe82c03b 100644
--- a/tools/tests/test_steam_achievement_icons.py
+++ b/tools/tests/test_steam_achievement_icons.py
@@ -46,3 +46,16 @@ def test_generated_icons_are_256_rgb_and_locked_ones_are_grey(tmp_path):
assert unlocked.mode == locked.mode == "RGB"
r, g, b = locked.split()
assert ImageChops.difference(r, g).getbbox() is None and ImageChops.difference(g, b).getbbox() is None, f"{api}_locked.png is not greyscale"
+
+
+def test_committed_icons_match_what_the_script_draws_now(tmp_path):
+ # #2737: an edit to the drawing code, or a hand-edited PNG, must not leave the committed icons stale. Decoded pixels
+ # are compared, not PNG bytes, since compression may differ.
+ # Exact pixels depend on the Pillow version: CI pins pillow==12.3.0, as the script header does.
+ icons.main(["steam_achievement_icons.py", str(tmp_path)])
+ for api in icons.ICONS:
+ for state in ("unlocked", "locked"):
+ name = f"{api}_{state}.png"
+ with Image.open(tmp_path / name) as fresh, Image.open(COMMITTED / name) as committed:
+ assert fresh.size == committed.size and fresh.mode == committed.mode, name
+ assert ImageChops.difference(fresh, committed).getbbox() is None, f"{name} differs from what the script draws"
diff --git a/tools/tests/test_vehicle_review_sources.py b/tools/tests/test_vehicle_review_sources.py
index 6eeb8ed5a..996395970 100644
--- a/tools/tests/test_vehicle_review_sources.py
+++ b/tools/tests/test_vehicle_review_sources.py
@@ -5,9 +5,13 @@ Dakota followed (owner, 2 November 2026: "Over Tel Aviv, 15 May-11 Jun"; on #227
its -compatibility.fbx name. This fails when verify stops following
the move (it would then look for a model that is no longer there, or pass without checking the shipped one)."""
import importlib.util
+import json
+import shutil
import sys
from pathlib import Path
+import pytest
+
ROOT = Path(__file__).resolve().parents[2]
SCRIPT = ROOT / "unity/Assets/Editor/VehicleReviewSources.py"
SPITFIRE = "generated-1948-13-egyptian-spitfire"
@@ -49,6 +53,43 @@ def test_verify_passes_on_the_shipped_files():
sources().verify(ROOT)
+def shipped_copy(mod, dest):
+ # Copy exactly what verify() reads (sources.json, the archives, each model's colour map and FBX) into dest.
+ manifest = json.loads((ROOT / mod.SOURCES / "sources.json").read_text())
+ (dest / mod.SOURCES).mkdir(parents=True)
+ shutil.copyfile(ROOT / mod.SOURCES / "sources.json", dest / mod.SOURCES / "sources.json")
+ for item in manifest["items"]:
+ if not (dest / mod.SOURCES / item["archive"]).exists(): # two items share one archive; copy it once
+ shutil.copyfile(ROOT / mod.SOURCES / item["archive"], dest / mod.SOURCES / item["archive"])
+ home = mod.home(item["id"])
+ (dest / home).mkdir(parents=True, exist_ok=True)
+ for name in (item["id"] + "_basecolor.jpg", mod.fbx_name(item["id"])):
+ shutil.copyfile(ROOT / home / name, dest / home / name)
+
+
[email protected]("target", [
+ "archive ZIP",
+ "base-colour JPEG",
+ "compatibility FBX",
+])
+def test_verify_fails_on_one_changed_byte(tmp_path, target):
+ # #2737: test_verify_passes_on_the_shipped_files stays green if verify() is a no-op. This one fails then.
+ mod = sources()
+ shipped_copy(mod, tmp_path)
+ mod.verify(tmp_path) # the untouched copy passes, so a broken copy can't make the raise below pass for the wrong reason
+ path = {
+ "archive ZIP": tmp_path / mod.SOURCES / "statecraft-vehicles-aircraft-01.zip",
+ "base-colour JPEG": tmp_path / mod.home(SPITFIRE) / (SPITFIRE + "_basecolor.jpg"),
+ "compatibility FBX": tmp_path / mod.home(R35) / mod.fbx_name(R35),
+ }[target]
+ assert path.is_relative_to(tmp_path) # never flip a byte in a committed file
+ blob = bytearray(path.read_bytes())
+ blob[len(blob) // 2] ^= 0xFF
+ path.write_bytes(bytes(blob))
+ with pytest.raises(AssertionError):
+ mod.verify(tmp_path)
+
+
def test_loading_the_script_writes_no_bytecode_under_assets():
# The script lives in unity/Assets/Editor. A __pycache__ written there gets a .meta from the next Unity run, which leaves
# the tree dirty and stops a gate that needs a clean one.