Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/evidence/text-native/regression-vs-main.py # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / evidence / text-native / regression-vs-main.py` 42 lines ยท 3070 bytes Raw Blame History 1 """Evidence probe (test infrastructure): compare the private emitter built from main's src/toc.om 2 with the current one over every committed source and every emitter mode. Prints each difference 3 class; the expected classes are listed in README.md next to this file.""" 4 import hashlib, json, os, pathlib, subprocess, sys 5 ROOT = pathlib.Path(__file__).resolve().parents[2] 6 OLD, NEW = pathlib.Path(sys.argv[1]), ROOT / 'build/bridge' # argv[1]: emitter built from main's toc.om 7 OLD_TOC, NEW_TOC = pathlib.Path(sys.argv[2]), ROOT / 'src/toc.om' # argv[2]: main's toc.om 8 srcs = {} 9 for pat in ('tests/fixtures/*.om', 'tests/freest-fixtures/*.om', 'tests/cabi/*.om', 'tests/unsupported/*.om', 'tests/native/*.om'): 10 for f in sorted(ROOT.glob(pat)): srcs[str(f.relative_to(ROOT))] = f.read_bytes() 11 for r in json.loads((ROOT / 'tests/refusals.json').read_text()): srcs['refusals:' + r['name']] = r['source'].encode() 12 def emit(exe, toc, mode, src): 13 """Run one private emitter with the wrapper's exact stdin framing; fd 3 carries toc.om for cabi.""" 14 digest = hashlib.sha256(toc.read_bytes()).hexdigest().encode() 15 data = bytes([mode]) + src 16 if mode in (76, 77, 86): data += b'\n%s %s\n' % (digest, hashlib.sha256(src).hexdigest().encode()) 17 with open(toc, 'rb') as fd3: 18 r = subprocess.run([str(exe)], input=data, capture_output=True, timeout=60, close_fds=False, 19 preexec_fn=lambda: os.dup2(fd3.fileno(), 3)) 20 return r.returncode, r.stdout.replace(digest, b''), r.stderr 21 modes = [67, 80, 68, 81, 72, 76, 77, 86, 69, 74, 82, 83, 87, 89] 22 # The two intended non-text changes: readonly C views gain const; the Python o_buf prelude 23 # line accepts bytes for readonly uchar views. Anything else that differs is listed as unexplained. 24 EXPLAINED = [(b'const void *', b'void *'), 25 (b'return (type(p) is bytearray or (edit==2 and type(p) is bytes)) and len(p)==n', b'return type(p) is bytearray and len(p)==n')] 26 def normal(out): 27 for new, old in EXPLAINED: out = out.replace(new, old) 28 return out 29 same = 0; diffs = [] 30 for name, src in srcs.items(): 31 for m in modes: 32 a, b = emit(OLD, OLD_TOC, m, src), emit(NEW, NEW_TOC, m, src) 33 if a == b: same += 1; continue 34 kind = 'explained' if a[0] == b[0] and normal(a[1]) == normal(b[1]) and a[2] == b[2] else 'status-or-bytes' 35 diffs.append(dict(source=name, mode=chr(m), kind=kind, old_status=a[0], new_status=b[0], 36 old_sha=hashlib.sha256(a[1]).hexdigest()[:16], new_sha=hashlib.sha256(b[1]).hexdigest()[:16])) 37 other = [d for d in diffs if d['kind'] != 'explained'] 38 report = dict(sources=len(srcs), modes=len(modes), comparisons=len(srcs) * len(modes), identical=same, 39 explained=len(diffs) - len(other), other=len(other), diffs=diffs) 40 (ROOT / 'evidence/text-native/regression-vs-main.json').write_text(json.dumps(report, indent=2) + '\n') 41 print(json.dumps({k: v for k, v in report.items() if k != 'diffs'})) 42 for d in other: print(d['source'], d['mode'], d['old_status'], '->', d['new_status'])