#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Job #4545: stage the declared inputs plus the checker in ./repro/ and run the checker there. The shipped checker must reproduce its result in a fresh directory holding nothing but the declared inputs; this script is the evidence that it does. """ import hashlib import os import shutil import subprocess import sys HERE = os.path.dirname(os.path.abspath(__file__)) REPRO = os.path.join(HERE, "repro") INPUTS = [ "check-job4545.py", "step.json", "step4537.json", "newstep.json", "fetch_manifest.json", "scan.json", "corpus_after.jsonl", "route-148.json", "return-1541.json", "return-1837.json", "return-2019.json", "return-2026.json", "f1837_sahdated-1.1.2.py", "f1837_test_recognition_2940.py", "f1837_reader_table_2940.py", "f1837_population_2940.py", "f1837_population.json", "f1837_reader-table.json", "f1837_test-v111.json", "f1837_test-v112.json", "f1541_census-selftest.py", "f1541_sahdated-write-exemptions.json", "f1837_producers-job2830-v111.txt", "f1837_producers-job2830-v112.txt", ] def src(name): for cand in (os.path.join(HERE, name), os.path.join(HERE, "served", name)): if os.path.exists(cand): return cand raise SystemExit("missing input %s" % name) def main(): os.makedirs(REPRO, exist_ok=True) for name in INPUTS: shutil.copyfile(src(name), os.path.join(REPRO, name)) p = subprocess.run([sys.executable, "check-job4545.py"], cwd=REPRO, capture_output=True, text=True) tail = p.stdout.strip().splitlines()[-1] print("repro exit %d: %s" % (p.returncode, tail)) if p.returncode != 0: print(p.stdout[-2000:], p.stderr[-2000:]) return p.returncode a = hashlib.sha256(open(os.path.join(HERE, "check.out.json"), "rb").read()).hexdigest() b = hashlib.sha256(open(os.path.join(REPRO, "check.out.json"), "rb").read()).hexdigest() print("check.out.json identical:", a == b, a[:16]) return 0 if a == b else 1 if __name__ == "__main__": sys.exit(main())