From b29b8b4b9cfe744e48b479c3a50b8717a3d195d0 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 21 May 2026 12:09:33 +0000 Subject: [PATCH] cmdtest.py: new `--dev-mode` option --- test/cmdtest.py | 2 ++ test/cmdtest_d/include/pexpect.py | 3 ++- test/cmdtest_d/include/runner.py | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/cmdtest.py b/test/cmdtest.py index 92574ca9..c8dfd3d5 100755 --- a/test/cmdtest.py +++ b/test/cmdtest.py @@ -122,6 +122,8 @@ opts_data = { -x, --debug-pexpect Produce debugging output for pexpect calls --, --demo Add extra delay after each send to make input visible. Implies --exact-output --pexpect-spawn --buf-keypress +--, --dev-mode Run spawned scripts in Python Development Mode + (PYTHONDEVMODE=1 PYTHONTRACEMALLOC=10) -d, --deps-only Run a command or command subgroup’s dependencies without running the command or command group itself. -D, --no-daemon-stop Don't stop auto-started daemons after running tests diff --git a/test/cmdtest_d/include/pexpect.py b/test/cmdtest_d/include/pexpect.py index 32c08aec..ea9ba5a2 100755 --- a/test/cmdtest_d/include/pexpect.py +++ b/test/cmdtest_d/include/pexpect.py @@ -67,7 +67,8 @@ class CmdTestPexpect: timeout = int( timeout or cfg.pexpect_timeout - or cfg.test_suite_pexpect_timeout) or (60, 5)[bool(cfg.debug_pexpect)] + or cfg.test_suite_pexpect_timeout) or ( + 5 if cfg.debug_pexpect else 180 if cfg.dev_mode else 60) if pexpect_spawn: self.p = pexpect.spawn(args[0], args[1:], encoding='utf8', timeout=timeout, env=spawn_env) else: diff --git a/test/cmdtest_d/include/runner.py b/test/cmdtest_d/include/runner.py index 86a69068..06d6ffae 100755 --- a/test/cmdtest_d/include/runner.py +++ b/test/cmdtest_d/include/runner.py @@ -105,14 +105,19 @@ class CmdTestRunner: def set_spawn_env(self): self.spawn_env = dict(os.environ) + self.spawn_env.update({ 'MMGEN_NO_LICENSE': '1', 'MMGEN_BOGUS_SEND': '1', 'MMGEN_TEST_SUITE_PEXPECT': '1', 'EXEC_WRAPPER_DO_RUNTIME_MSG':'1', # if cmdtest.py itself is running under exec_wrapper, disable writing of traceback file for spawned script - 'EXEC_WRAPPER_TRACEBACK': '' if os.getenv('MMGEN_EXEC_WRAPPER') else '1', - }) + 'EXEC_WRAPPER_TRACEBACK': '' if os.getenv('MMGEN_EXEC_WRAPPER') else '1'}) + + if self.cfg.dev_mode: + self.spawn_env.update({ + 'PYTHONDEVMODE': '1', + 'PYTHONTRACEMALLOC': '10'}) if self.cfg.exact_output: from mmgen.term import get_terminal_size