Datasets:
Download scripts/reusable_support/case_guards.py from CrossSWE/CrossSWE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/reusable_support/case_guards.py
- Command line
-
hf download hf://datasets/CrossSWE/CrossSWE-Bench/scripts/reusable_support/case_guards.py
-
curl -L -o case_guards.py https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/reusable_support/case_guards.py
2.01 kB
| """Admission guards for complete pytest evidence and world/repeat coverage.""" | |
| def report_health(report, expected_ids=None): | |
| if not isinstance(report, dict): | |
| return ['Missing pytest report'] | |
| issues = [] | |
| ids = report.get('collected', []) | |
| if not ids or len(ids) != len(set(ids)): | |
| issues.append('Empty or duplicate case collection') | |
| if report.get('testscollected') != len(ids): | |
| issues.append('Collection count mismatch') | |
| if expected_ids is not None and set(ids) != set(expected_ids): | |
| issues.append('Case inventory drift') | |
| if report.get('collection_errors') or report.get('internal_errors'): | |
| issues.append('Collection or internal error') | |
| reports = report.get('reports', []) | |
| if set(x.get('nodeid') for x in reports) != set(ids): | |
| issues.append('Case report coverage mismatch') | |
| calls = [] | |
| for nodeid in ids: | |
| phases = [x for x in reports if x.get('nodeid') == nodeid] | |
| if sorted(x.get('when', '') for x in phases) != ['call', 'setup', 'teardown']: | |
| issues.append(f'Incomplete/duplicate phases: {nodeid}') | |
| for p in phases: | |
| if p.get('when') == 'call': | |
| calls.append(p.get('outcome')) | |
| if p.get('outcome') not in ('passed', 'failed') or p.get('wasxfail'): | |
| issues.append(f'Skipped/xfail/unknown case: {nodeid}') | |
| elif p.get('outcome') != 'passed': | |
| issues.append(f'Setup/teardown error: {nodeid}') | |
| expected_exit = 1 if 'failed' in calls else 0 | |
| if report.get('exitstatus') != expected_exit: | |
| issues.append('Exit status disagrees with case outcomes') | |
| return issues | |
| def matrix_health(runs, worlds, repeats): | |
| from collections import Counter | |
| actual = Counter((r.get('world'), r.get('repeat')) for r in runs) | |
| expected = Counter((w, n) for w in worlds for n in range(1, repeats + 1)) | |
| return [] if actual == expected else ['Missing, duplicate or unexpected world/repeat'] | |