from pathlib import Path import hashlib import json import os import subprocess import time from datetime import datetime, timezone root = Path(__file__).resolve().parent repo = root.parent.parent oracle = repo / '.local/staged-source-oracle-20260911/staged-source-authoring-contract.exe' expected_hash = '967d9ba3c6fb3a7efb410833903ec94556ca2d48a67d5072c8bb160f40a00f9c' assert hashlib.sha256(oracle.read_bytes()).hexdigest() == expected_hash runtime = repo / '.local/toolchain/llvm-mingw-20260826-ucrt-x86_64/bin' assert (runtime / 'libunwind.dll').is_file() env = os.environ.copy() system_root = next(value for key, value in env.items() if key.lower() == 'systemroot') env['PATH'] = str(runtime) + ';' + system_root + '/System32;' + system_root env['RUST_BACKTRACE'] = '0' results = [] for label, left, right, expected_success in [ ('valid-same', 'valid-baseline', 'valid-work', True), ('release1-same', 'release1-baseline', 'release1-work', True), ('ambiguous-rejected', 'ambiguous-open', 'ambiguous-open', False), ('missing-include-rejected', 'missing-include-open', 'missing-include-open', False), ]: args = [str(oracle), 'same', str(root / left / 'project.arcadia'), str(root / right / 'project.arcadia')] assert not (root / (label + '-result.json')).exists() started = time.monotonic() process = subprocess.run(args, cwd=root, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=45) (root / (label + '.stdout.log')).write_bytes(process.stdout) (root / (label + '.stderr.log')).write_bytes(process.stderr) result = {'command': args, 'oracle_sha256': expected_hash, 'exit': process.returncode, 'expected_success': expected_success, 'expectation_met': (process.returncode == 0) == expected_success, 'seconds': time.monotonic() - started, 'finished_utc': datetime.now(timezone.utc).isoformat()} (root / (label + '-result.json')).write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8') results.append(result) print(label, process.returncode, process.stdout.decode('utf-8', errors='replace').strip()) manifest = json.loads((root / 'fixture-manifest.json').read_text(encoding='utf-8')) assert all(hashlib.sha256((root / entry['path']).read_bytes()).hexdigest() == entry['sha256'] for entry in manifest) (root / 'check-summary.json').write_text(json.dumps({'results': results, 'all_fixture_bytes_unchanged': True, 'runtime_sha256': hashlib.sha256((runtime / 'libunwind.dll').read_bytes()).hexdigest()}, indent=2) + '\n', encoding='utf-8') assert all(result['expectation_met'] for result in results)