Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
38 lines
2.4 KiB
Python
38 lines
2.4 KiB
Python
from pathlib import Path
|
|
import sys,hashlib,json,subprocess,importlib.util,time,traceback
|
|
R=Path('/home/jakub/devel/escapistsrereintroduced/.build/mounted-native-1456');B=Path('/tmp/erri-mounted-native-root-1456');sys.path.insert(0,str(R/'tools'))
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
from source_manifest import addon_manifest
|
|
inputs=addon_manifest(R)
|
|
inputs.update({str(p.relative_to(R)):sha(p) for folder in ['tests','tools'] for p in (R/folder).rglob('*') if p.is_file() and '__pycache__' not in p.parts and p.suffix != '.pyc'})
|
|
inputs.update({str(p.relative_to(R)):sha(p) for p in (R/'docs').iterdir() if p.is_file()})
|
|
(B/'suite-inputs.json').write_text(json.dumps(inputs,indent=2)+'\n')
|
|
prior=json.loads((B/'quota-suite-failure/suite-result.json').read_text())
|
|
prior_inputs=json.loads((B/'quota-suite-failure/suite-inputs.json').read_text())
|
|
assert inputs==prior_inputs
|
|
reused={p['path'] for p in prior['programs'][:-1]}
|
|
original=subprocess.run;programs=[]
|
|
def track(args,*a,**kw):
|
|
entry=None
|
|
if isinstance(args,list) and len(args)>1 and str(args[1]).startswith(str(R/'tests')+'/'):
|
|
entry={'path':str(Path(args[1]).relative_to(R)),'exit':None};programs.append(entry)
|
|
if entry['path'] in reused:
|
|
entry.update(exit=0,reused_from='quota-suite-failure/suite-result.json')
|
|
print('REUSED unchanged bound pass:',entry['path'])
|
|
return subprocess.CompletedProcess(args,0)
|
|
try:result=original(args,*a,**kw)
|
|
except subprocess.CalledProcessError as error:
|
|
if entry is not None:entry['exit']=error.returncode
|
|
raise
|
|
if entry is not None:entry['exit']=result.returncode
|
|
return result
|
|
subprocess.run=track
|
|
spec=importlib.util.spec_from_file_location('repository_check',R/'tools/check.py');module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
|
|
code=0;started=time.monotonic()
|
|
try:module.check()
|
|
except Exception:traceback.print_exc();code=1
|
|
unchanged=all((R/p).is_file() and sha(R/p)==h for p,h in inputs.items());code=code or int(not unchanged)
|
|
(B/'suite-result.json').write_text(json.dumps({'exit':code,'seconds':round(time.monotonic()-started,2),'inputs_unchanged':unchanged,'regression_programs':len(programs),'programs':programs,'resumed':True,'reused_bound_passes':len(reused),'fresh_programs':len(programs)-len(reused),'temporary_directory':'/tmp'},indent=2)+'\n')
|
|
print('Suite exit',code,'programs',len(programs),'unchanged',unchanged)
|
|
raise SystemExit(code)
|