From 06f914e2a8705531dbefb7c4b56a3e7fdc453e9e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 7 Dec 2022 10:40:53 +0000 Subject: [PATCH] test.include.pexpect: add `timeout` param --- test/include/pexpect.py | 6 +++--- test/test.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/include/pexpect.py b/test/include/pexpect.py index 72bf9489..a48f8704 100755 --- a/test/include/pexpect.py +++ b/test/include/pexpect.py @@ -40,7 +40,7 @@ NL = '\n' class MMGenPexpect: - def __init__(self,args,no_output=False,env=None,pexpect_spawn=False,send_delay=None): + def __init__(self,args,no_output=False,env=None,pexpect_spawn=False,send_delay=None,timeout=None): self.pexpect_spawn = pexpect_spawn self.send_delay = send_delay @@ -53,7 +53,7 @@ class MMGenPexpect: from subprocess import run,DEVNULL run([args[0]] + args[1:],check=True,stdout=DEVNULL if no_output else None) else: - timeout = int(opt.pexpect_timeout or 0) or (60,5)[bool(opt.debug_pexpect)] + timeout = int(timeout or opt.pexpect_timeout or 0) or (60,5)[bool(opt.debug_pexpect)] if pexpect_spawn: self.p = pexpect.spawn(args[0],args[1:],encoding='utf8',timeout=timeout,env=env) else: @@ -198,7 +198,7 @@ class MMGenPexpect: m1 = f'\nERROR. Expect {s!r} timed out. Exiting\n' m2 = f'before: [{self.p.before}]\n' m3 = f'sent value: [{self.sent_value}]' if self.sent_value != None else '' - die(2,m1+m2+m3) + raise pexpect.TIMEOUT(m1+m2+m3) if opt.debug_pexpect: debug_pexpect_msg(self.p) diff --git a/test/test.py b/test/test.py index ccba2f4f..a7d4936e 100755 --- a/test/test.py +++ b/test/test.py @@ -569,6 +569,7 @@ class TestSuiteRunner(object): no_msg = False, cmd_dir = 'cmds', no_exec_wrapper = False, + timeout = None, pexpect_spawn = None ): desc = self.ts.test_name if opt.names else self.gm.dpy_data[self.ts.test_name][1] @@ -641,6 +642,7 @@ class TestSuiteRunner(object): no_output = no_output, env = env, pexpect_spawn = pexpect_spawn, + timeout = timeout, send_delay = send_delay ) def end_msg(self):