import datetime,importlib.util,json,os,pathlib,re,subprocess,sys,time sys.dont_write_bytecode=True r=pathlib.Path(__file__).resolve().parent;p=r.parent.parent spec=importlib.util.spec_from_file_location('row276_driver',p/'driver.py');d=importlib.util.module_from_spec(spec);spec.loader.exec_module(d) root=pathlib.Path('/mnt/storage/scratch/gander276-measure-kp71qj') rows=[] for n in range(1,6): for label,sha in [('before','804a854dc'),('after','f3a55ddf7')]: d.REPO=root/label actual=subprocess.check_output(['git','rev-parse','HEAD'],cwd=d.REPO,text=True).strip();assert actual.startswith(sha) original=subprocess.check_output(['git','status','--porcelain','--untracked-files=no'],cwd=d.REPO) tmp=subprocess.check_output(['mktemp','-d','/mnt/storage/scratch/tmp/gXXX'],text=True).strip();os.environ['TMPDIR']=tmp name=f'{n}-{label}' print('START',name,actual,tmp,flush=True) v=d.run(['node','--test','--test-reporter=tap','--test-name-pattern','row253 C4 P10 inner reason','packages/cli/tests/case1-accept.test.mjs'],r/(name+'.log')) text=(r/(name+'.log')).read_text() v.update(repetition=n,label=label,sha=actual,tmpdir=tmp,duration_ms=float(re.search(r'duration_ms: ([0-9.]+)',text)[1]),reported_mode_seconds=dict(re.findall(r'(exec|hop): ([0-9.]+)s',text))) rows.append(v);(r/'results.json').write_text(json.dumps(rows,indent=2)+'\n') assert subprocess.check_output(['git','status','--porcelain','--untracked-files=no'],cwd=d.REPO)==original if v['timeout']:raise RuntimeError('measurement timeout, stop') print('END',name,json.dumps(v),flush=True) print('MEASUREMENTS COMPLETE',flush=True)