"""Verify artifacts: check required output files exist and parse as JSON.
Usage: verify_report.py [file...] — exit 0 if all OK."""
import json, os, sys
def main():
required = [a for a in sys.argv[1:]] or ["report.json"]
bad = []
for path in required:
if not os.path.exists(path):
bad.append(f"{path}: missing")
else:
with open(path, encoding="utf-8") as f:
try:
json.load(f)
except Exception as e:
bad.append(f"{path}: invalid JSON ({e})")
for b in bad:
print(f"FAIL {b}")
print("ALL PASS" if not bad else f"{len(bad)} artifact(s) failed")
return 1 if bad else 0
if __name__ == "__main__":
try:
sys.exit(main())
except Exception as exc:
print(f"FAIL unexpected error: {exc}")
sys.exit(1)