@@ -86,26 +86,42 @@ def _clean(full: dict) -> dict:
8686 return out
8787
8888
89- def main ():
89+ def main (check_only : bool = False ):
90+ """Regenerate templates, or check they're up to date (--check flag)."""
91+ stale = False
9092 for name , overrides in _TEMPLATES .items ():
9193 test_type = TestType .OFFLINE if name == "offline" else TestType .ONLINE
9294 try :
9395 base = BenchmarkConfig .create_default_config (test_type )
9496 cfg = base .with_updates (** overrides )
9597 except (CLIError , ValueError ) as e :
96- print (f" Skip: { name } ({ e } )" )
98+ print (f" FAIL: { name } ({ e } )" )
99+ stale = True
97100 continue
98101
99- path = TEMPLATES_DIR / f"{ name } _template.yaml"
100- path .write_text (
101- yaml .dump (
102- _clean (cfg .model_dump (mode = "json" )),
103- default_flow_style = False ,
104- sort_keys = False ,
105- )
102+ expected = yaml .dump (
103+ _clean (cfg .model_dump (mode = "json" )),
104+ default_flow_style = False ,
105+ sort_keys = False ,
106106 )
107- print (f" Generated: { path .name } " )
107+ path = TEMPLATES_DIR / f"{ name } _template.yaml"
108+
109+ if check_only :
110+ current = path .read_text () if path .exists () else ""
111+ if current != expected :
112+ print (f" STALE: { path .name } " )
113+ stale = True
114+ else :
115+ print (f" OK: { path .name } " )
116+ else :
117+ path .write_text (expected )
118+ print (f" Generated: { path .name } " )
119+
120+ if stale :
121+ raise SystemExit (1 )
108122
109123
110124if __name__ == "__main__" :
111- main ()
125+ import sys
126+
127+ main (check_only = "--check" in sys .argv )
0 commit comments