version_port.py harnesses: horizon-prepare and every harness in the candidate, newly failing ones in the report

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-15 18:16:57 +02:00
parent b3bc3c0768
commit ec0725aeb0
5 changed files with 335 additions and 14 deletions
+62
View File
@@ -0,0 +1,62 @@
from pathlib import Path
import tempfile
import unittest
from tools import port_harness as harness
JAVAC = """/x/mods/horizon/src/test/java/dev/horizonlab/parity/ParityData.java:45: error: cannot find symbol
symbol: variable WORLD
location: class RegistryLayer
1 error
"""
def state(**statuses):
return {"harnesses": {name.replace("_1", "#1"): {"status": status} for name, status in statuses.items()}}
class ClassifyTests(unittest.TestCase):
def setUp(self):
self.directory = tempfile.TemporaryDirectory()
self.logs = Path(self.directory.name)
(self.logs / "food.log").write_text(JAVAC)
(self.logs / "food_extra.log").write_text("not food's log")
(self.logs / "light.log").write_text("first difference at (3, 64, 2)")
def tearDown(self):
self.directory.cleanup()
def test_pass_oracle_fail_and_new(self):
now = state(food="fail", light="fail", mob_ai="fail", move="pass", move_1="fail")
baseline = state(food="pass", light="pass", mob_ai="fail", move="pass")
found = harness.classify(now, self.logs, baseline)
self.assertEqual(found["food"], {"status": "oracle", "baseline": "pass", "new": True, "compile_errors": [
"ParityData.java:45: cannot find symbol: variable WORLD (class RegistryLayer)"]})
self.assertEqual(found["light"], {"status": "fail", "baseline": "pass", "new": True})
self.assertEqual(found["mob_ai"], {"status": "fail", "baseline": "fail", "new": False})
self.assertEqual(found["move"]["status"], "fail") # one shard failed
self.assertEqual(harness.summary(found), {"pass": 0, "oracle": 1, "fail": 3, "new": 3, "known": 1})
def test_without_a_baseline_every_failure_is_new(self):
found = harness.classify(state(light="fail", food="pass"), self.logs)
self.assertTrue(found["light"]["new"])
self.assertFalse(found["food"]["new"])
def test_named_harnesses_only(self):
self.assertEqual(list(harness.classify(state(light="fail", food="pass"), self.logs, names=["food"])), ["food"])
def test_logs_of_one_harness(self):
(self.logs / "food#2.log").write_text("")
self.assertEqual([p.name for p in harness.harness_logs(self.logs, "food")], ["food#2.log", "food.log"])
class AssetTests(unittest.TestCase):
def test_sounds_and_panorama_only(self):
self.assertTrue(harness.wanted_asset("minecraft/sounds.json"))
self.assertTrue(harness.wanted_asset("minecraft/sounds/mob/cow/say1.ogg"))
self.assertTrue(harness.wanted_asset("minecraft/textures/gui/title/background/panorama_overlay.png"))
self.assertFalse(harness.wanted_asset("minecraft/lang/fr_fr.json"))
if __name__ == "__main__":
unittest.main()
+22 -2
View File
@@ -62,11 +62,31 @@ def diff():
class PortReportTests(unittest.TestCase):
def build(self, results=None, regen=None):
def build(self, results=None, regen=None, harnesses=None):
with mock.patch.object(report, "version_sites", return_value=["crates/p/src/lib.rs:20"]), \
mock.patch.object(report, "files_naming", return_value=["crates/p/src/play.rs"]), \
mock.patch.object(report, "files_containing", return_value=["crates/w/src/blocks.rs"]):
return report.build(diff(), mapping(), "26.2", "26.3", {"id": "26.3"}, results, regen=regen)
return report.build(diff(), mapping(), "26.2", "26.3", {"id": "26.3"}, results, regen=regen,
harnesses=harnesses)
def test_harness_results_count_only_new_failures(self):
ran = {"prepare": {"status": "failed", "error": "javac exited 1",
"compile_errors": ["VanillaBlockExporter.java:9: cannot find symbol: class Foo"]},
"summary": {"pass": 1, "oracle": 1, "fail": 2, "new": 2, "known": 1},
"harnesses": {"food": {"status": "oracle", "baseline": "pass", "new": True, "compile_errors": ["X"]},
"move": {"status": "fail", "baseline": "fail", "new": False},
"light": {"status": "fail", "baseline": "pass", "new": True},
"sky": {"status": "pass", "baseline": "pass", "new": False}}}
built = self.build(harnesses=ran)
[prepare] = [i for i in built["items"] if i["kind"] == "prepare-failed"]
self.assertEqual(prepare["rank"], 1)
failed = {h: i for i in built["items"] for h in i.get("failed", [])}
self.assertEqual(failed["food"]["oracle"], ["food"])
self.assertNotIn("move", failed) # It fails on the old version too.
self.assertEqual(failed["light"]["title"], "Harness light: fails on 26.3")
text = report.markdown(built)
self.assertIn("1 pass, 1 whose oracle no longer compiles, 2 fail; 2 newly failing, 1 failing on 26.2 too", text)
self.assertIn("- javac: `VanillaBlockExporter.java:9: cannot find symbol: class Foo`", text)
def test_regen_results_replace_the_stale_tables(self):
regen = {"new": "26.3", "candidate": "/ports/26.3", "commit": "0123456789abcdef", "generators": {