test suite: exception handling fixes

This commit is contained in:
The MMGen Project 2023-10-04 13:58:40 +00:00
commit ae533adb3a
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 7 additions and 4 deletions

View file

@ -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',

View file

@ -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)

View file

@ -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