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

45 lines
3.6 KiB
Plaintext

from pathlib import Path
import sys,os,json,subprocess,time,fcntl
ROOT=Path('/home/jakub/devel/escapistsrereintroduced');sys.path.insert(0,str(ROOT/'tools'))
from headless_game import assert_prefix_idle,cleanup_owned_run
from external_addons import policy,prepare_profile
steam=Path.home()/'.local/share/Steam';compat=Path('/tmp/erri-headless-compat');profile=Path('/tmp/erri-nogova-escape-native1');profile.mkdir(exist_ok=True)
lock=(compat/'.erri-workbench.lock').open('a');fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB);assert_prefix_idle(compat)
addons=profile/'addons';addons.mkdir(exist_ok=True)
external=steam/'steamapps/compatdata/1874880/pfx/drive_c/users/steamuser/Documents/My Games/ArmaReforger/addons'
prepare_profile(addons,external,policy(ROOT),profile/'external-cache.json')
for name,target in [('ArmaReforger',steam/'steamapps/common/Arma Reforger/addons/data'),('ERR_Core',ROOT/'addons/core'),('Nogova',Path('/home/jakub/devel/gabreta/addons/NogovaReforger'))]:
link=addons/name
if not link.exists():link.symlink_to(target,target_is_directory=True)
proton=steam/'steamapps/common/Proton - Experimental/proton';wb=steam/'steamapps/common/Arma Reforger Tools/Workbench'
out=profile
cmd=['gamescope','--backend','headless','-W','1280','-H','720','-w','1280','-h','720','-r','30','--',str(proton),'run',str(wb/'ArmaReforgerWorkbenchSteamDiag.exe'),'-gproj','Z:'+str(ROOT/'terrain-adapters/nogova/addon.gproj'),'-profile','Z:'+str(profile),'-wbModule=WorldEditor','-load','Worlds/ERR_nogova.ent','-plugin=ERR_ValidateWorldPlugin','-errPlay','1', '-logconsole','-noSound','-noSplash','-noThrow','-disableCrashReporter']
env=os.environ.copy();env.update(STEAM_COMPAT_DATA_PATH=str(compat),STEAM_COMPAT_CLIENT_INSTALL_PATH=str(steam),WINEPREFIX=str(compat/'pfx'),PULSE_SINK='erri_tests_silent')
(profile/'command.json').write_text(json.dumps(cmd,indent=2))
from native_provenance import snapshot,persist,seal_run
captured=snapshot(ROOT,cmd)
import hashlib
adapter_root=ROOT/'terrain-adapters/nogova'
(profile/'adapter-launch-sha256.json').write_text(json.dumps({str(p.relative_to(adapter_root)):hashlib.sha256(p.read_bytes()).hexdigest() for p in adapter_root.rglob('*') if p.is_file() and p.suffix in ['.c','.gproj','.ent','.meta','.layer','.conf']},indent=2))
terrain=Path('/home/jakub/devel/gabreta/addons/NogovaReforger')
def terrain_inputs():
return {str(p.relative_to(terrain)):hashlib.sha256(p.read_bytes()).hexdigest() for p in terrain.rglob('*') if p.is_file() and p.suffix in ['.nmn','.et','.gproj','.ent','.meta','.layer','.conf','.c']}
terrain_before=terrain_inputs();(profile/'terrain-launch-sha256.json').write_text(json.dumps(terrain_before,indent=2))
child=None;started=time.time();session=None
with (profile/'launch.log').open('w') as log:
try:
child=subprocess.Popen(cmd,cwd=wb,env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
while time.time()-started<360 and child.poll() is None:
sessions=sorted((profile/'logs').glob('logs_*/console.log'))
if sessions:
if session is None:session=sessions[-1].parent;persist(session,captured)
logtext=sessions[-1].read_text(errors='replace')
if 'scenario preparation failed' in logtext or 'Reintroduced [spawn]: player ' in logtext:break
time.sleep(1)
finally:
if child:
report=cleanup_owned_run(child,proton,env,compat);(profile/'cleanup.json').write_text(json.dumps(report,indent=2));print(report)
if session:(session/'source-seal.json').write_text(json.dumps(seal_run(ROOT,session,captured),indent=2))
(profile/'terrain-unchanged.json').write_text(json.dumps({'unchanged':terrain_before==terrain_inputs()}))
print('Nogova Escape startup test finished; see',profile)