vile / scheme / testdata / check_transcoders.py
18 lines · 18 sloc · 1.5 KB · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1"""Manual replay of independent transcoder fixtures through a supplied CLI."""
2from pathlib import Path
3import subprocess,sys,json,hashlib
4if len(sys.argv) not in [2,3]:raise SystemExit('usage: check_transcoders.py BINARY [REPORT_JSON]')
5binary=str(Path(sys.argv[1]).resolve());fixture=Path(__file__).with_name('transcoders.tsv')
6rows=[line.split('\t') for line in fixture.read_text().splitlines() if line and not line.startswith(';')]
7valid=[r for r in rows if r[0]=='text'];errors=[r for r in rows if r[0]=='error']
8for at in range(0,len(valid),32):
9 batch=valid[at:at+32];cmd=[binary,'-s']
10 for _,source,_ in batch:cmd+=['-e',source]
11 p=subprocess.run(cmd,capture_output=True,text=True,timeout=30);assert p.returncode==0 and not p.stderr,(batch,p.stderr)
12 lines=p.stdout.splitlines();assert len(lines)==len(batch),(batch,lines)
13 for (_,source,wanted),actual in zip(batch,lines):assert actual==wanted,(source,actual,wanted)
14for _,source,_ in errors:
15 p=subprocess.run([binary,'-s','-e',source],capture_output=True,text=True,timeout=10);assert p.returncode!=0 and p.stderr,(source,p.stdout)
16report={'status':'passed','fixture_cases':len(rows),'successful_outputs':len(valid),'expected_errors':len(errors),'binary_sha256':hashlib.sha256(Path(binary).read_bytes()).hexdigest(),'fixture_sha256':hashlib.sha256(fixture.read_bytes()).hexdigest(),'scope':'Manual independent fixture replay, not additional V test-function count.'}
17if len(sys.argv)==3:Path(sys.argv[2]).write_text(json.dumps(report,indent=2)+'\n')
18print(json.dumps(report))
19