mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
Native hook stamping keeps the generated mod API current
The catalog takes a batch's new hooks and helpers in file name order, the order xtask mod-api reads pending fragments in; API numbers still follow merge order. Stamping used to append them in merge order, which reordered generated.rs.
This commit is contained in:
1 parent
c488e079f6
commit
cee65d7ce2
2 files changed
+8
-4
No files matched your search
@@ -72,7 +72,7 @@ class StampTests(unittest.TestCase):
|
||||
self.assertIn("API 9 adds a; requires 9.", docs)
|
||||
self.assertIn("NATIVE_HOOKS_API: u32 = 9;", source)
|
||||
hooks = json.loads((self.root / stamp.CATALOG).read_text())["hooks"]
|
||||
self.assertEqual([(h["name"], h["version"]) for h in hooks], [("z", 1), ("a", 1)])
|
||||
self.assertEqual([(h["name"], h["version"]) for h in hooks], [("a", 1), ("z", 1)])
|
||||
self.assertFalse(stamp.stamp(False))
|
||||
|
||||
def test_helper_only_gets_a_number(self):
|
||||
|
||||
@@ -52,10 +52,10 @@ def stamp(check):
|
||||
names = {hook["name"] for hook in catalog["hooks"]}
|
||||
helper_names = {helper["name"] for helper in catalog.get("helpers", [])}
|
||||
extra = {}
|
||||
for path in ordered:
|
||||
# The catalog takes new entries in file name order, the order `cargo run -p xtask -- mod-api`
|
||||
# reads pending fragments in, so stamping leaves the generated mod API as it was.
|
||||
for path in sorted(ordered):
|
||||
fragment = json.loads(path.read_text())
|
||||
version += 1
|
||||
marker = f"@API:{path.stem}@"
|
||||
for hook in fragment["hooks"]:
|
||||
if hook["name"] in names:
|
||||
raise ValueError(f"duplicate hook: {hook['name']}")
|
||||
@@ -69,6 +69,10 @@ def stamp(check):
|
||||
raise ValueError(f"duplicate helper: {helper['name']}")
|
||||
helper_names.add(helper["name"])
|
||||
catalog.setdefault("helpers", []).append(helper)
|
||||
for path in ordered:
|
||||
fragment = json.loads(path.read_text())
|
||||
version += 1
|
||||
marker = f"@API:{path.stem}@"
|
||||
rust_summary = fragment["rust_summary"].replace(marker, str(version))
|
||||
doc_summary = fragment["doc_summary"].replace(marker, str(version))
|
||||
if not rust_summary or not doc_summary:
|
||||
|
||||
Reference in new issue
Block a user