Files
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

36 lines
2.1 KiB
Python

from pathlib import Path
import sys,hashlib,json,subprocess,importlib.util,time,traceback,os
R=Path('/home/jakub/devel/escapistsrereintroduced');B=Path('/tmp/erri-gameplay-root-0011');sys.path.insert(0,str(R/'tools'))
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
from source_manifest import addon_manifest
def capture_inputs():
result=addon_manifest(R)
for folder in ['tests','tools','terrain-profiles','terrain-adapters','terrain-integrations']:
result.update({str(p.relative_to(R)):sha(p) for p in (R/folder).rglob('*') if p.is_file() and '__pycache__' not in p.parts and p.suffix != '.pyc'})
result.update({str(p.relative_to(R)):sha(p) for p in (R/'docs').iterdir() if p.is_file()})
for name in ['README.md','.gitignore']: result[name]=sha(R/name)
return result
inputs=capture_inputs()
(B/'suite-inputs.json').write_text(json.dumps(inputs,indent=2)+'\n')
removed_overrides={key:os.environ.pop(key) for key in list(os.environ) if key.startswith('ERR_')}
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)
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=capture_inputs()==inputs;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,'removed_override_names':sorted(removed_overrides),'regression_programs':len(programs),'programs':programs},indent=2)+'\n')
print('Suite exit',code,'programs',len(programs),'unchanged',unchanged)
raise SystemExit(code)