Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tools/corpus_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ def run_checker(bin_path, hy_path, report_managed=False):
# Parse failures have no managed report. A report that is present
# must carry the usize counters emitted by hy_diag::ManagedReport;
# silently defaulting malformed counters to zero hides audit drift.
if managed is not None:
# An accepted program must carry a managed report when requested.
if managed is None:
if verdict == "accept":
raise RuntimeError(
f"checker managed report missing for {hy_path}: "
"accepted program omitted summary.managed"
)
else:
if not isinstance(managed, dict):
raise RuntimeError(f"checker managed report invalid for {hy_path}: expected an object")
for field in ("managed_blocks", "sites_via_managed", "total_sites"):
Expand Down
14 changes: 14 additions & 0 deletions tools/test_corpus_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,20 @@ def test_absent_or_null_report_keeps_parser_reject_contract(self):
self.assertIn("verdict agreement: 1/1", run.stdout)
self.assertNotIn("Traceback", run.stderr)

def test_missing_or_null_report_on_accept_fails_closed(self):
# Issue #3251: an accepted response lacking summary.managed must fail closed
# instead of silently aggregating missing data as zero counters.
self.assert_invalid_report(None)
payload = {
"summary": {"verdict": "accept", "errors": 0, "warnings": 0},
"diagnostics": [],
}
run = self.run_cases([("ACCEPT", payload, 0)])
self.assertEqual(run.returncode, 1, run.stdout + run.stderr)
self.assertIn("harness-error", run.stdout)
self.assertIn("verdict agreement: 0/1", run.stdout)
self.assertNotIn("Traceback", run.stderr)

def test_report_validation_only_applies_with_report_flag(self):
for managed in (False, 0, "", [], [1], "x",
{"managed_blocks": -1, "sites_via_managed": 5,
Expand Down
Loading