From eee778660907b4c43332e2c2be931369bc61bd08 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:53:28 +0200 Subject: [PATCH] Generated version facts through lab.version_info; options and world harnesses take the data version from the jar Co-Authored-By: Claude Opus 5.5 --- tests/test_gen_version_consts.py | 2 +- tools/gen_version_consts.py | 10 ++-------- tools/test_options_parity.py | 2 +- tools/test_world_parity.py | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/tests/test_gen_version_consts.py b/tests/test_gen_version_consts.py index 61b12e62f6..36daee8490 100644 --- a/tests/test_gen_version_consts.py +++ b/tests/test_gen_version_consts.py @@ -33,7 +33,7 @@ class GenVersionConstsTests(unittest.TestCase): jar = Path(directory) / "client.jar" with zipfile.ZipFile(jar, "w") as archive: archive.writestr("version.json", json.dumps(INFO)) - self.assertEqual(gen.jar_info(jar), INFO) + self.assertEqual(lab.version_info(jar), INFO) def test_committed_file_is_the_pinned_version(self): """A pin bump regenerates version.rs: the lock and the constants never disagree.""" diff --git a/tools/gen_version_consts.py b/tools/gen_version_consts.py index 07cecd747e..41e0b1192e 100644 --- a/tools/gen_version_consts.py +++ b/tools/gen_version_consts.py @@ -15,7 +15,6 @@ from datetime import datetime, timezone import json from pathlib import Path import sys -import zipfile try: from . import lab @@ -25,11 +24,6 @@ except ImportError: OUT = lab.ROOT / "crates/horizon-core/src/version.rs" -def jar_info(client_jar): - with zipfile.ZipFile(client_jar) as archive: - return json.loads(archive.read("version.json")) - - def java_date(iso): """`Date.toString()` of an ISO-8601 instant, in UTC (Locale.ROOT names).""" return datetime.fromisoformat(iso).astimezone(timezone.utc).strftime("%a %b %d %H:%M:%S UTC %Y") @@ -69,8 +63,8 @@ def main(): parser.add_argument("--out", type=Path, default=OUT) parser.add_argument("--check", action="store_true", help="exit 1 if --out differs instead of writing it") args = parser.parse_args() - jar = args.jar or lab.config()[1] / "jars" / "client.jar" - text = render(jar_info(jar)) + jar = args.jar or lab.GAME / "jars" / "client.jar" + text = render(lab.version_info(jar)) if args.check: if not args.out.exists() or args.out.read_text() != text: print(f"{args.out} does not match {jar}; run tools/gen_version_consts.py", file=sys.stderr) diff --git a/tools/test_options_parity.py b/tools/test_options_parity.py index cf7698e5ce..e99f67a44c 100644 --- a/tools/test_options_parity.py +++ b/tools/test_options_parity.py @@ -13,7 +13,7 @@ try: except ImportError: import lab, oracle_harness as harness -VERSION = 5023 +VERSION = lab.version_info()['world_version'] # Raw JSON-ish value texts: valid, boundary, wrong-typed, lenient-parser and # syntax-error forms. Syntax errors abort the rest of a load, as in vanilla. diff --git a/tools/test_world_parity.py b/tools/test_world_parity.py index 9f4bb5d529..802dc38849 100644 --- a/tools/test_world_parity.py +++ b/tools/test_world_parity.py @@ -96,7 +96,7 @@ def main(): references.append({"side": side, "jar_sha256": lab.digest(jars[side], "sha256"), **results[0]}) print(json.dumps(references[-1]), flush=True) test_rust_parity.ensure_sources_unchanged(sources, tested_sources) - report = {"schema": 1, "minecraft": lock["minecraft"]["version"], "data_version": 5023, + report = {"schema": 1, "minecraft": lock["minecraft"]["version"], "data_version": lab.version_info()["world_version"], "platform": platform.platform(), "java": run(["java", "--version"]).splitlines()[0], "rustc": run(["rustc", "--version"]).strip(), "references": references, "sources_sha256": tested_sources,