from pathlib import Path
import subprocess,os,json,time
root=Path('/tmp/lead-33181-r1/capture')
run=root/'run-20261110-05'
run.mkdir()
results=[]
for side,path in [('before','/home/user/wt/pr-33181-before'),('after','/home/user/wt/pr-33181')]:
 for width in [1440,390]:
  for theme in ['light','dark']:
   name=f'{side}-{width}-{theme}'
   env={**os.environ,'EVIDENCE_OUT':str(run/name),'EVIDENCE_WIDTH':str(width),'EVIDENCE_THEME':theme}
   with (run/(name+'.log')).open('w') as log:
    result=subprocess.run(['vp','test','run','src/components/chat/ThreadRelationshipsEvidence.browser.test.tsx','--config','evidence.config.ts'],cwd=path+'/apps/web',env=env,stdout=log,stderr=subprocess.STDOUT)
   results.append({'name':name,'exit':result.returncode})
   (run/'results.json').write_text(json.dumps(results,indent=2))
   print(name,result.returncode,flush=True)
   if result.returncode:print((run/(name+'.log')).read_text(),flush=True);raise SystemExit(1)
