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

40 lines
3.1 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-terrain-generic-native2');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')]:
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/'.build/terrain-generic-test/addon.gproj'),'-profile','Z:'+str(profile),'-wbModule=WorldEditor','-load','Worlds/ERR_everon_generic_test.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/'.build/terrain-generic-test'
(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))
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<210 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 [mission]: phase 0 -> 1' 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))
print('Generic-terrain test finished; see',profile)