Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
29 lines
2.2 KiB
Python
29 lines
2.2 KiB
Python
"""Actual argparse admission for the bounded supply travel fixture; no process launch."""
|
|
from pathlib import Path
|
|
import argparse,ast,contextlib,io,os
|
|
from policy_harness import ROOT
|
|
p=Path(os.environ.get('ERR_SUPPLY_TRAVEL_RUNNER',ROOT/'tools/headless_workbench.py'))
|
|
tree=ast.parse(p.read_text()); declarations=[]; guards=[]
|
|
for node in tree.body:
|
|
if isinstance(node,ast.Assign) and any(isinstance(t,ast.Name) and t.id=='p' for t in node.targets):declarations.append(node)
|
|
if isinstance(node,ast.Expr) and isinstance(node.value,ast.Call) and isinstance(node.value.func,ast.Attribute) and isinstance(node.value.func.value,ast.Name) and node.value.func.value.id=='p' and node.value.func.attr=='add_argument':declarations.append(node)
|
|
if isinstance(node,ast.If) and any(isinstance(n,ast.Constant) and n.value=='supply-travel' for n in ast.walk(node.test)):
|
|
assert any(isinstance(n,ast.Call) and isinstance(n.func,ast.Attribute) and n.func.attr=='error' for n in ast.walk(node))
|
|
guards.append(node)
|
|
assert len(guards)==1
|
|
scope={'argparse':argparse,'Path':Path,'__doc__':__doc__}
|
|
exec(compile(ast.Module(body=declarations,type_ignores=[]),str(p),'exec'),scope)
|
|
parser=scope['p']; choices=next(a.choices for a in parser._actions if a.dest=='smoke')
|
|
assert choices.count('supply-travel')==1 and 'supply-convoys' in choices and 'convoy' in choices
|
|
base=['--compat','/tmp/erri-unused-supply-travel-prefix','--profile','/tmp/erri-unused-supply-travel-profile']
|
|
def check(smoke='supply-travel',project='chat',rounds='1',timeout='480'):
|
|
args=parser.parse_args(base+['--smoke',smoke,'--project',project,'--rounds',rounds,'--timeout',timeout]);scope['a']=args
|
|
try:
|
|
with contextlib.redirect_stderr(io.StringIO()):exec(compile(ast.Module(body=guards,type_ignores=[]),str(p),'exec'),scope)
|
|
except SystemExit as e:assert e.code==2;return False
|
|
return True
|
|
assert check() and check(timeout='600')
|
|
assert not check(project='core') and not check(rounds='2') and not check(rounds='0') and not check(timeout='479')
|
|
assert check(smoke='normal-escape-route',project='core',rounds='2',timeout='90')
|
|
print('PASS: actual supply-travel selector requires Chat, one round and480s; existing outcomes unaffected; no native launch')
|