From ae533adb3a0ff17d1ab3842fa63aca6611560f04 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 4 Oct 2023 13:58:40 +0000 Subject: [PATCH] test suite: exception handling fixes --- mmgen/cfg.py | 2 ++ scripts/exec_wrapper.py | 6 +++--- test/test.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 119b10c4..e3f3a0f3 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -202,6 +202,7 @@ class Config(Lockable): bogus_unspent_data = '' debug_utf8 = False exec_wrapper = False + ignore_test_py_exception = False test_suite = False test_suite_autosign_led_simulate = False test_suite_xmr_autosign = False @@ -314,6 +315,7 @@ class Config(Lockable): 'MMGEN_TESTNET', 'MMGEN_REGTEST', 'MMGEN_EXEC_WRAPPER', + 'MMGEN_IGNORE_TEST_PY_EXCEPTION', 'MMGEN_RPC_BACKEND', 'MMGEN_IGNORE_DAEMON_VERSION', 'MMGEN_USE_STANDALONE_SCRYPT_MODULE', diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index 8535e89b..7b8ddd89 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -16,10 +16,10 @@ def exec_wrapper_init(): if exec_wrapper_os.path.dirname(exec_wrapper_sys.argv[1]) == 'test': 'support running of test scripts under wrapper' cwd = exec_wrapper_os.getcwd() # assume we’re in repo root - exec_wrapper_sys.path[1] = cwd + exec_wrapper_sys.path[0] = cwd + exec_wrapper_sys.path[1] = exec_wrapper_os.path.join(cwd,'test') from test.overlay import get_overlay_tree_dir - exec_wrapper_sys.path[0] = get_overlay_tree_dir(cwd) - exec_wrapper_sys.path.insert(2, exec_wrapper_os.path.join(cwd,'test')) + exec_wrapper_sys.path.insert(0, get_overlay_tree_dir(cwd)) else: exec_wrapper_sys.path.pop(0) diff --git a/test/test.py b/test/test.py index 7eb49199..65bb9a9a 100755 --- a/test/test.py +++ b/test/test.py @@ -1038,7 +1038,8 @@ except TestSuiteSpawnedScriptException as e: Msg(blue('test.py: spawned script exited with error')) except Exception: # if test.py itself is running under exec_wrapper, re-raise so exec_wrapper can handle exception: - if os.getenv('MMGEN_EXEC_WRAPPER'): + if os.getenv('MMGEN_EXEC_WRAPPER') or not os.getenv('MMGEN_IGNORE_TEST_PY_EXCEPTION'): raise + die(1,red('Test script exited with error')) except: raise