From 7b61eccbb7370a21c20ef45ff3963582c12c2a9d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 6 May 2023 15:14:06 +0000 Subject: [PATCH] MMGenPexpect: new `direct_exec` param --- test/include/pexpect.py | 11 ++++++----- test/test.py | 11 +++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/test/include/pexpect.py b/test/include/pexpect.py index 79705621..8fbb0baf 100755 --- a/test/include/pexpect.py +++ b/test/include/pexpect.py @@ -45,7 +45,8 @@ class MMGenPexpect: env = None, pexpect_spawn = False, send_delay = None, - timeout = None ): + timeout = None, + direct_exec = False ): self.pexpect_spawn = pexpect_spawn self.send_delay = send_delay @@ -53,10 +54,10 @@ class MMGenPexpect: self.skip_ok = False self.sent_value = None - if cfg.direct_exec: - msg('') - from subprocess import run,DEVNULL - run([args[0]] + args[1:],check=True,stdout=DEVNULL if no_output else None) + if direct_exec or cfg.direct_exec: + from subprocess import Popen,DEVNULL + redir = DEVNULL if (no_output or not cfg.exact_output) else None + self.ep = Popen([args[0]] + args[1:], stderr=redir ) else: timeout = int(timeout or cfg.pexpect_timeout or 0) or (60,5)[bool(cfg.debug_pexpect)] if pexpect_spawn: diff --git a/test/test.py b/test/test.py index 0e7b39fa..5ee48a28 100755 --- a/test/test.py +++ b/test/test.py @@ -579,7 +579,8 @@ class TestSuiteRunner(object): cmd_dir = 'cmds', no_exec_wrapper = False, timeout = None, - pexpect_spawn = None ): + pexpect_spawn = None, + direct_exec = False ): desc = self.ts.test_name if cfg.names else self.gm.dpy_data[self.ts.test_name][1] if extra_desc: @@ -624,9 +625,10 @@ class TestSuiteRunner(object): clr2(repr(cmd_disp) if gc.platform == 'win' else cmd_disp) ) else: - omsg_r('{a}Testing {b}: '.format( + omsg_r('{a}Testing {b}: {c}'.format( a = t_pfx, - b = desc ) + b = desc, + c = 'OK\n' if direct_exec or cfg.direct_exec else '')) if msg_only: return @@ -654,7 +656,8 @@ class TestSuiteRunner(object): env = env, pexpect_spawn = pexpect_spawn, timeout = timeout, - send_delay = send_delay ) + send_delay = send_delay, + direct_exec = direct_exec ) def end_msg(self): t = int(time.time() - self.start_time)