| @@ -73,16 +73,16 @@ def main(): |
| 73 | 73 | try: |
| 74 | 74 | rc, out, err = run_counter(counter, config) |
| 75 | 75 | except subprocess.TimeoutExpired: |
| 76 | | - fail(f"{case.name}: {counter.parent.parent.name} timed out") |
| 76 | + fail(f"{case.name}: {counter.parent.name} timed out") |
| 77 | 77 | continue |
| 78 | 78 | if rc != 0: |
| 79 | | - fail(f"{case.name}: {counter.parent.parent.name} exited {rc}: {err.splitlines()[:1]}") |
| 79 | + fail(f"{case.name}: {counter.parent.name} exited {rc}: {err.splitlines()[:1]}") |
| 80 | 80 | continue |
| 81 | 81 | try: |
| 82 | 82 | data = json.loads(out) |
| 83 | | - claims[counter.parent.parent.name] = (data["n"], data["unit_circles"], parse_centres(data["centers"])) |
| 83 | + claims[counter.parent.name] = (data["n"], data["unit_circles"], parse_centres(data["centers"])) |
| 84 | 84 | except (json.JSONDecodeError, KeyError, ValueError) as exc: |
| 85 | | - fail(f"{case.name}: {counter.parent.parent.name} printed unusable output ({exc})") |
| 85 | + fail(f"{case.name}: {counter.parent.name} printed unusable output ({exc})") |
| 86 | 86 | |
| 87 | 87 | if artifact is not None: |
| 88 | 88 | try: |
| @@ -109,23 +109,37 @@ def main(): |
| 109 | 109 | continue |
| 110 | 110 | agreed += 1 |
| 111 | 111 | |
| 112 | + |
| 113 | + |
| 114 | + contract = sorted((args.corpus / "contract").iterdir()) if (args.corpus / "contract").exists() else [] |
| 115 | + for case in contract: |
| 116 | + if artifact is None: |
| 117 | + continue |
| 118 | + proc = subprocess.run([sys.executable, str(Path(args.artifact) / "verify.py"), str(case), |
| 119 | + "--output", str(args.corpus / "contract-out.json")], |
| 120 | + capture_output=True, text=True, timeout=TIMEOUT) |
| 121 | + if proc.returncode != 1: |
| 122 | + fail(f"contract/{case.name}: artifact exited {proc.returncode}, expected 1") |
| 123 | + |
| 112 | 124 | for case in invalid: |
| 113 | 125 | config = case / "configuration.json" |
| 114 | 126 | for counter in args.counters: |
| 115 | 127 | try: |
| 116 | 128 | rc, out, err = run_counter(counter, config) |
| 117 | 129 | except subprocess.TimeoutExpired: |
| 118 | | - fail(f"invalid/{case.name}: {counter.parent.parent.name} timed out") |
| 130 | + fail(f"invalid/{case.name}: {counter.parent.name} timed out") |
| 119 | 131 | continue |
| 120 | | - name = counter.parent.parent.name |
| 132 | + name = counter.parent.name |
| 121 | 133 | if rc != 1: |
| 122 | 134 | fail(f"invalid/{case.name}: {name} exited {rc}, expected 1") |
| 123 | 135 | elif out: |
| 124 | 136 | fail(f"invalid/{case.name}: {name} printed to stdout on rejection") |
| 125 | 137 | |
| 126 | | - names = ", ".join(c.parent.parent.name for c in args.counters) + (", pr4 verify.unit_centers" if artifact else "") |
| 138 | + names = ", ".join(c.parent.name for c in args.counters) + (", pr4 verify.unit_centers" if artifact else "") |
| 127 | 139 | print(f"\n{agreed}/{len(cases)} valid cases agreed across: {names}") |
| 128 | 140 | print(f"{len(invalid)} invalid cases checked for exit 1 and empty stdout") |
| 141 | + if contract: |
| 142 | + print(f"{len(contract)} claim-contract cases checked against the artifact only") |
| 129 | 143 | print(f"{len(failures)} failure(s)") |
| 130 | 144 | return 0 if not failures else 1 |
| 131 | 145 | |