Datasets:
Download scripts/batch06_candidate_case_reports_v1.py from CrossSWE/CrossSWE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 5.44 kB
-
https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/batch06_candidate_case_reports_v1.py
- Command line
-
hf download hf://datasets/CrossSWE/CrossSWE-Bench/scripts/batch06_candidate_case_reports_v1.py
-
curl -L -o batch06_candidate_case_reports_v1.py https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/batch06_candidate_case_reports_v1.py
5.44 kB
| """Candidate-only native parsing; frozen baseline helpers are never modified. | |
| Original Conda16510 assertion failures remain the existing outer regression | |
| case. The 16 original pytest leaves are retained as nested evidence only. | |
| """ | |
| import collections | |
| import re | |
| import xml.etree.ElementTree as ET | |
| def auth_units(stdout, saved, frozen): | |
| need = frozen.need | |
| summary = frozen.one(frozen.prefixed(stdout, 'CROSSSWE_UNIT_SUMMARY '), 'original pytest unit summary') | |
| units = summary['results'] | |
| need(isinstance(units, list) and all(isinstance(row, dict) for row in units), 'Malformed unit results') | |
| classes = {'tests.test_credentials': 'tests.test_credentials', 'test_credentials': 'tests.test_credentials', | |
| 'tests.test_storage': 'tests.test_storage', 'test_storage': 'tests.test_storage'} | |
| need(all(row.get('classname') in classes for row in units), 'Unfrozen original pytest module') | |
| need(collections.Counter((classes[row['classname']], row.get('name')) for row in units) == | |
| collections.Counter(frozen.AUTH_UNITS), 'Original pytest unit inventory mismatch') | |
| need(all(row.get('status') in ('passed', 'failed') for row in units), 'Original unit skipped or unknown') | |
| rows = [{'id': classes[row['classname']] + '::' + row['name'], 'passed': row['status'] == 'passed'} for row in units] | |
| failed = sum(not row['passed'] for row in rows) | |
| frozen.totals(summary, rows, int(failed > 0), total='executed') | |
| path = saved.file('conda-original-units.xml') | |
| root = ET.parse(path).getroot() | |
| need(root.tag in ('testsuite', 'testsuites'), 'Malformed original pytest JUnit root') | |
| need(not list(root.iter('error')) and not list(root.iter('skipped')), 'Original pytest JUnit error or skipped unit') | |
| xml_rows = [] | |
| for case in root.iter('testcase'): | |
| need(len(case.findall('failure')) <= 1, 'Malformed repeated pytest assertion failure') | |
| xml_rows.append((case.get('classname'), case.get('name'), 'failed' if case.find('failure') is not None else 'passed')) | |
| need(collections.Counter(xml_rows) == collections.Counter((row['classname'], row['name'], row['status']) for row in units), | |
| 'JUnit disagrees with printed original-unit summary') | |
| suites = list(root.iter('testsuite')) | |
| need(len(suites) == 1, 'Expected one complete pytest suite') | |
| for key, expected in (('tests', 16), ('failures', failed), ('errors', 0), ('skipped', 0)): | |
| need(suites[0].get(key) == str(expected), 'Original pytest suite count mismatch: ' + key) | |
| return {'nested_native_tests': 16, 'nested_native_passed': 16 - failed, 'nested_native_failed': failed, | |
| 'nested_cases': rows, 'nested_count_unit': 'original pytest parametrized leaf case; excluded from outer denominator', | |
| 'nested_junit_sha256': frozen.digest(path)} | |
| def parse_report(iid, repository, kind, stdout, stderr, returncode, cell, *, frozen): | |
| """Keep the frozen case inventory; reinterpret only complete auth assertions.""" | |
| if (iid, repository, kind) != ('buildpkg-conda-16510', 'conda-auth', 'pass_to_pass'): | |
| return frozen.parse_report(iid, repository, kind, stdout, stderr, returncode, cell) | |
| try: | |
| need = frozen.need | |
| need(isinstance(stdout, str) and isinstance(stderr, str), 'Logs must be text') | |
| frozen.no_infrastructure(stdout + '\n' + stderr) | |
| for line in stdout.splitlines(): | |
| marker = re.match(r'^(CROSSSWE_[A-Z_]+|D710_[A-Z_]+|BEHAVIOR_ARTIFACT|CONTRACT_[A-Z_]+|NATIVE_[A-Z_]+)(?:\s|$)', line) | |
| if marker: | |
| need(marker.group(1) in {'CROSSSWE_ORIGIN', 'CROSSSWE_DIAGNOSTIC_OUTPUT', | |
| 'CROSSSWE_UNIT_SUMMARY', 'CROSSSWE_SUMMARY'}, 'Unexpected native protocol marker') | |
| origins = [line.split() for line in stdout.splitlines() if line.startswith('CROSSSWE_ORIGIN ')] | |
| need(origins == [['CROSSSWE_ORIGIN', 'conda', frozen.CONDA + 'conda/__init__.py'], | |
| ['CROSSSWE_ORIGIN', 'conda_auth', '/testbed/conda-incubator/conda-auth/conda_auth/__init__.py']], | |
| 'Missing or incorrect candidate import origins') | |
| saved = frozen.SavedEvidence(cell) | |
| source = saved.source() | |
| need(all(row[2] in source for row in origins), 'Imported origin missing from captured candidate source') | |
| summary = frozen.one(frozen.prefixed(stdout, 'CROSSSWE_SUMMARY '), 'native summary') | |
| need(summary['repo'] == repository and summary['group'] == 'p2p', 'Summary repository/phase mismatch') | |
| rows = frozen.inventory(summary['results'], frozen.INVENTORIES[iid][repository]['p2p'], statuses=('passed', 'failed')) | |
| meta = frozen.totals(summary, rows, returncode, total='executed') | |
| nested = auth_units(stdout, saved, frozen) | |
| parent = next(row for row in rows if row['id'] == 'frozen_credentials_storage_units') | |
| need(parent['passed'] is (nested['nested_native_failed'] == 0), 'Original units disagree with their outer regression case') | |
| meta.update(nested) | |
| meta.update(format='candidate scoped Conda/auth summary results', expected_native_tests=len(rows), | |
| candidate_parser_version=1) | |
| return rows, [], meta | |
| except (frozen.EvidenceError, ValueError, KeyError, TypeError, AttributeError, IndexError, OSError, ET.ParseError) as exc: | |
| return [], ['Incomplete/malformed native evidence: ' + type(exc).__name__ + ': ' + str(exc)], {} | |