# Question(job575): does #205's patch reproduce its upload, does its printer # inspect documents, and do the frozen Var41 intervals match its gap report? import json,hashlib,tempfile,subprocess,shutil,re from fractions import Fraction as F from pathlib import Path p=Path(__file__).parent.resolve() with tempfile.TemporaryDirectory() as d: q=Path(d);shutil.copy(p/'QUESTIONS.base.md',q/'QUESTIONS.md') subprocess.run(['patch','--silent',str(q/'QUESTIONS.md'),str(p/'questions.patch')],check=True) assert (q/'QUESTIONS.md').read_bytes()==(p/'uploaded-QUESTIONS.md').read_bytes() def printed():return subprocess.check_output(['python',str(p/'uploaded-registry_sweep.py')],cwd=q,stderr=subprocess.DEVNULL) clean=printed();(q/'QUESTIONS.md').write_text('Deliberately invalid fixture: every status CLOSED.\n');changed=printed();assert clean==changed changedrows=[] for i,(a,b) in enumerate(zip((p/'QUESTIONS.base.md').read_text().splitlines(),(p/'uploaded-QUESTIONS.md').read_text().splitlines()),1): if a!=b:changedrows.append({'line':i,'id':re.search(r'`(Q-[^`]+)`',a).group(1)}) source=(p/'var41-prereg.md').read_text() assert '239.7 h on one core' in source and 'ten cores that is 24.0 h' in source assert '240 h wall clock on eight cores' in (p/'report205.md').read_text() center=F('0.4024');radius=F('0.0016');lo=center-radius;hi=center+radius assert lo==F('0.4008') and hi==F('0.4040') def verdict(r):return 'HELD' if abs(r-center)<=radius else 'FAIL_LOW' if rF('.4048') else 'UNASSIGNED' witnesses={str(r):verdict(F(r)) for r in ['0.3999','0.4000','0.4004','0.4008','0.4013','0.4040','0.4044','0.4048','0.4049']} assert witnesses['0.4004']==witnesses['0.4044']=='UNASSIGNED' out={'uploaded_patch_reproduced':True,'index_changed_rows':changedrows,'report_printer_same_on_corrupt_input':True,'printed_sha256':hashlib.sha256(clean).hexdigest(),'var41_held_interval':[str(lo),str(hi)],'var41_gap_witnesses':witnesses,'source_one_core_hours':'239.7','source_ten_core_ideal_hours':'24.0','eight_core_ideal_hours':'29.9625','eight_core_240h_claim_supported':False} (p/'check205.json').write_text(json.dumps(out,indent=2)+'\n');print(json.dumps(out,indent=2))