import os,subprocess,json from pathlib import Path p=Path('/tmp/erri-launcher-resupply-1140');root=Path('/home/jakub/devel/escapistsrereintroduced');env=os.environ.copy();env.update(PYTHONDONTWRITEBYTECODE='1',PYTHONPATH=str(p/'tests')+':'+str(root/'tests')) for key,name in [('ERR_INFANTRY_TRANSFER_SOURCE','ERR_InfantryAmmoTransfer.c'),('ERR_INFANTRY_RESUPPLY_SOURCE','ERR_InfantryResupply.c'),('ERR_HQ_SOURCE','ERR_HQ.c'),('ERR_AMMO_SOURCE','ERR_HQAmmoSampler.c')]:env[key]=str(p/'addons/core/Scripts/Game/ERR/10_AI'/name) results={} for name in ['test_hq_ammo_sampler.py','test_infantry_ammo_transfer.py','test_infantry_resupply_planning.py','test_infantry_resupply_coordinator.py','test_mounted_supply_integration.py','test_hq_multiconvoy_supply.py','test_hq_ammo_reporting.py','test_hq_watch.py','test_infantry_mine_coordinator.py','test_infantry_supply_pool.py','test_hq_status_sampler.py']: f=p/'tests'/name if not f.exists():f=root/'tests'/name r=subprocess.run(['python3',str(f)],env=env,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) (p/('final-'+name+'.log')).write_text(r.stdout);results[name]=r.returncode;print(name,r.returncode,flush=True) if r.returncode:print(r.stdout[-5000:]) (p/'final-results.json').write_text(json.dumps(results,indent=2)+'\n') assert not any(results.values())