Browse Source

test suite: exception handling fixes

The MMGen Project 1 year ago
parent
commit
ae533adb3a
3 changed files with 7 additions and 4 deletions
  1. 2 0
      mmgen/cfg.py
  2. 3 3
      scripts/exec_wrapper.py
  3. 2 1
      test/test.py

+ 2 - 0
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',

+ 3 - 3
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)
 

+ 2 - 1
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