Preserve raw include diagnostic provenance and derive bands from the existing shaped editor. Retain deferred tooltip paragraphs through rendering. Include source, regression, failure and native-trial evidence; corrected native acceptance remains pending.
33 lines
2.2 KiB
Python
33 lines
2.2 KiB
Python
from pathlib import Path
|
|
import datetime, hashlib, json, os, subprocess, sys, time
|
|
|
|
base = Path(__file__).resolve().parent
|
|
record = base / 'records' / sys.argv[1]
|
|
record.mkdir(parents=True, exist_ok=False)
|
|
def now(): return datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
def digest(path):
|
|
data = path.read_bytes()
|
|
return {'bytes': len(data), 'sha256': hashlib.sha256(data).hexdigest()}
|
|
def inputs():
|
|
return {p.relative_to(base).as_posix(): digest(p) for p in sorted(base.rglob('*'))
|
|
if p.is_file() and p.relative_to(base).parts[0] not in ('records', 'target')}
|
|
before = inputs()
|
|
(record / 'inputs.json').write_text(json.dumps(before, indent=2), encoding='utf-8')
|
|
cmd = ['cargo', 'run', '--locked', '--offline', '--manifest-path', str(base / 'Cargo.toml')]
|
|
report = {'start': now(), 'command': cmd, 'cwd': str(base), 'inputs': digest(record / 'inputs.json'),
|
|
'environment': {k: os.environ.get(k) for k in ('RUSTUP_TOOLCHAIN', 'RUSTUP_HOME', 'CARGO_HOME', 'CARGO_TARGET_DIR', 'CARGO_BUILD_JOBS', 'CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER')},
|
|
'cargo': subprocess.check_output(['cargo', '--version'], text=True).strip(),
|
|
'rustc': subprocess.check_output(['rustc', '--version'], text=True).strip()}
|
|
(record / 'started.json').write_text(json.dumps(report, indent=2), encoding='utf-8')
|
|
t = time.perf_counter()
|
|
with (record / 'stdout.log').open('xb') as stdout, (record / 'stderr.log').open('xb') as stderr:
|
|
result = subprocess.run(cmd, cwd=base, stdout=stdout, stderr=stderr)
|
|
report.update(finish=now(), seconds=time.perf_counter()-t, exitCode=result.returncode,
|
|
stdout=digest(record/'stdout.log'), stderr=digest(record/'stderr.log'), inputsUnchanged=before == inputs())
|
|
report['passLine'] = [line for line in (record/'stdout.log').read_text(encoding='utf-8').splitlines() if line.startswith('PASS ')]
|
|
exe = Path(os.environ['CARGO_TARGET_DIR']) / 'debug' / 'text-diagnostics-geometry-probe.exe'
|
|
if exe.exists(): report['binary'] = {'path': str(exe), **digest(exe)}
|
|
(record / 'result.json').write_text(json.dumps(report, indent=2), encoding='utf-8')
|
|
print(json.dumps(report, indent=2))
|
|
sys.exit(0 if result.returncode == 0 and report['inputsUnchanged'] and len(report['passLine']) == 1 else 1)
|