| 1 | """Manual replay of independent transcoder fixtures through a supplied CLI.""" |
| 2 | from pathlib import Path |
| 3 | import subprocess,sys,json,hashlib |
| 4 | if len(sys.argv) not in [2,3]:raise SystemExit('usage: check_transcoders.py BINARY [REPORT_JSON]') |
| 5 | binary=str(Path(sys.argv[1]).resolve());fixture=Path(__file__).with_name('transcoders.tsv') |
| 6 | rows=[line.split('\t') for line in fixture.read_text().splitlines() if line and not line.startswith(';')] |
| 7 | valid=[r for r in rows if r[0]=='text'];errors=[r for r in rows if r[0]=='error'] |
| 8 | for 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) |
| 14 | for _,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) |
| 16 | report={'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.'} |
| 17 | if len(sys.argv)==3:Path(sys.argv[2]).write_text(json.dumps(report,indent=2)+'\n') |
| 18 | print(json.dumps(report)) |
| 19 | |