29 lines
1.8 KiB
Python
29 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Print native test commands; never launch a window implicitly."""
|
|
import argparse,json,subprocess
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument('mode',choices=['workbench','server'])
|
|
p.add_argument('--exe',required=True,type=Path)
|
|
p.add_argument('--profile',required=True,type=Path)
|
|
p.add_argument('--smoke',choices=['victory','lost-helicopter','player-death', 'radio-network', 'hq-response', 'mortar-inventory'],help='Opt-in Workbench test; use a disposable profile')
|
|
p.add_argument('--execute',action='store_true',help='Deliberately execute the command; Workbench opens a window')
|
|
p.add_argument('--visible-output',help='User-approved spare display; required when executing Workbench')
|
|
a=p.parse_args()
|
|
if a.smoke and a.mode!='workbench':p.error('Scripted smoke is compiled only for Workbench')
|
|
if a.execute and a.mode=='workbench' and not a.visible_output:
|
|
p.error('Workbench opens windows. Select/configure a spare display and supply --visible-output first.')
|
|
command=[str(a.exe),'-addonsDir',str(ROOT/'addons'),'-profile',str(a.profile),'-logconsole']
|
|
if a.mode=='workbench':
|
|
command+=['-gproj',str(ROOT/'addons/chat/addon.gproj'),'-wbModule=WorldEditor','-load','Worlds/ERR_Everon.ent']
|
|
if a.smoke:command+=['-plugin','ERR_ValidateWorldPlugin','-errPlay','1','-errSmoke','1','-errSmokeOutcome',a.smoke]
|
|
else:
|
|
if 'server' not in a.exe.name.lower():p.error('Use an actual dedicated server binary for background tests.')
|
|
command+=['-addons','ERR_Chat','-server','Worlds/ERR_Everon.ent','-maxFPS','60','-logStats','1000']
|
|
print(json.dumps(command,indent=2))
|
|
if a.execute:
|
|
if not a.exe.is_file():p.error('Executable not found')
|
|
# This helper does not move windows or change desktop settings.
|
|
raise SystemExit(subprocess.call(command))
|