24 lines
1.6 KiB
Python
24 lines
1.6 KiB
Python
from pathlib import Path
|
|
import datetime,hashlib,json,os,subprocess
|
|
OUT=Path(__file__).resolve().parent
|
|
pre=json.loads((OUT/'preflight.json').read_text())
|
|
def now(): return datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
status=json.loads((OUT/'runner-status.json').read_text())
|
|
original=(OUT/'coverage-probe.ps1').read_text()
|
|
code=original.replace("$runRoot = Join-Path $taskRoot 'rest'","$runRoot = Join-Path $taskRoot 'rest-strict'")
|
|
code=code.replace(' $script:launch++'," $script:launch++\n # PowerShell startup prepends PSHOME; reset only this process before launching.\n $env:PATH = '"+pre['server_PATH'].replace("'","''")+"'")
|
|
assert code!=original
|
|
(OUT/'coverage-probe-strict.ps1').write_text(code,encoding='utf-8')
|
|
cmd=list(status[0]['command']);cmd[3]=str(OUT/'coverage-probe-strict.ps1')
|
|
env=dict(os.environ);env['PATH']=pre['server_PATH'];env.pop('ARCADIA_SERVER_TOKEN',None)
|
|
started=now()
|
|
with (OUT/'rest-strict.stdout.log').open('wb') as out,(OUT/'rest-strict.stderr.log').open('wb') as err:
|
|
proc=subprocess.Popen(cmd,cwd=pre['cwd'],env=env,stdout=out,stderr=err,creationflags=subprocess.CREATE_NO_WINDOW)
|
|
result={'name':'rest-strict','pid':proc.pid,'command':cmd,'started':started,'exit_code':proc.wait(),'finished':now()}
|
|
status.append(result)
|
|
(OUT/'runner-status.json').write_text(json.dumps(status,indent=2))
|
|
print(json.dumps(result),flush=True)
|
|
after={name:hashlib.sha256(Path(name).read_bytes()).hexdigest().upper() for name in pre['inputs']}
|
|
(OUT/'postflight.json').write_text(json.dumps({'finished':now(),'inputs':after,'all_inputs_unchanged':pre['inputs']==after},indent=2))
|
|
assert result['exit_code']==0 and pre['inputs']==after
|