Skip to content

Commit d455096

Browse files
committed
Add logging for json_compare when in CI
1 parent fdd4178 commit d455096

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/json_compare.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44
from pathlib import Path
5+
from pprint import pformat
56

67
working_dir = Path(os.environ["PDM_RUN_CWD"] if "PDM_RUN_CWD" in os.environ else "./")
78

@@ -11,13 +12,21 @@
1112
gold_path = gold_path if gold_path.is_absolute() else working_dir / gold_path
1213
gate_path = gate_path if gate_path.is_absolute() else working_dir / gate_path
1314

15+
def on_ci():
16+
if "CI" in os.environ and os.environ["CI"]:
17+
return True
18+
return False
19+
1420
def main():
1521
with open(gold_path, "r") as f:
1622
gold = json.load(f)
1723
with open(gate_path, "r") as f:
1824
gate = json.load(f)
1925
if len(gold["events"]) != len(gate["events"]):
2026
print(f"Failed! Event mismatch: {len(gold['events'])} events in reference, {len(gate['events'])} in test output")
27+
if on_ci():
28+
print(f"Test Output:\n{pformat(gate)}\n")
29+
print(f"Reference events:\n{pformat(gold)}\n")
2130
return 1
2231
for ev_gold, ev_gate in zip(gold["events"], gate["events"]):
2332
if ev_gold["peripheral"] != ev_gate["peripheral"] or \

0 commit comments

Comments
 (0)