20 lines
1.8 KiB
Python
20 lines
1.8 KiB
Python
from pathlib import Path
|
|
import datetime,hashlib,json,os,subprocess
|
|
root=Path(__file__).resolve().parents[1];run=root/'.local/native46'
|
|
record=json.loads((run/'baseline.json').read_text(encoding='utf-8'))
|
|
bin=run/'bin';exe=bin/'arcadia-studio.exe'
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
assert sha(exe)==record['binary']['sha256'] and sha(bin/'libunwind.dll')==record['runtime']['sha256']
|
|
work=run/'working';work.mkdir(exist_ok=False)
|
|
env=os.environ.copy();system=os.environ['SystemRoot'];env['PATH']=str(Path(system)/'System32')+';'+system
|
|
for k in list(env):
|
|
if k.startswith(('CARGO_','RUST','LLVM','WGPU','ARCADIA_')):del env[k]
|
|
receipt={'source':record['source'],'start':datetime.datetime.now(datetime.timezone.utc).isoformat(),'binary_sha256':sha(exe),'runtime_sha256':sha(bin/'libunwind.dll'),'cwd':str(work),'path':env['PATH']}
|
|
with (run/'stdout.log').open('xb') as out,(run/'stderr.log').open('xb') as err:
|
|
child=subprocess.Popen([str(exe)],cwd=work,env=env,stdout=out,stderr=err,creationflags=subprocess.CREATE_NO_WINDOW)
|
|
receipt['pid']=child.pid;(run/'started.json').write_text(json.dumps(receipt,indent=2)+'\n',encoding='utf-8');print(json.dumps(receipt,indent=2),flush=True)
|
|
code=child.wait()
|
|
receipt.update({'exit_code':code,'finished':datetime.datetime.now(datetime.timezone.utc).isoformat(),'stdout_bytes':(run/'stdout.log').stat().st_size,'stderr_bytes':(run/'stderr.log').stat().st_size,'binary_unchanged':sha(exe)==record['binary']['sha256'],'runtime_unchanged':sha(bin/'libunwind.dll')==record['runtime']['sha256']})
|
|
(run/'finished.json').write_text(json.dumps(receipt,indent=2)+'\n',encoding='utf-8');print(json.dumps(receipt,indent=2),flush=True)
|
|
assert code==0 and receipt['stdout_bytes']==receipt['stderr_bytes']==0 and receipt['binary_unchanged'] and receipt['runtime_unchanged']
|