Add a debugger friendly option to the python test framework

* This suppresses the use of a global try/except to catch exceptions then log &
  continue. Instead it runs the test and lets the debugger catch any exceptions
  that happen.
This commit is contained in:
baldurk
2019-05-03 11:13:52 +01:00
parent a32bbb8232
commit 1bef46bfee
2 changed files with 18 additions and 6 deletions
+11 -5
View File
@@ -141,7 +141,7 @@ def _run_test(testclass, failedcases: list):
.format(test_run.returncode))
def run_tests(test_include: str, test_exclude: str, in_process: bool, slow_tests: bool):
def run_tests(test_include: str, test_exclude: str, in_process: bool, slow_tests: bool, debugger: bool):
start_time = time.time()
rd.InitGlobalEnv(rd.GlobalEnvironment(), [])
@@ -278,15 +278,21 @@ def run_tests(test_include: str, test_exclude: str, in_process: bool, slow_tests
util.set_current_test(name)
try:
def do():
if in_process:
instance = testclass()
instance.invoketest()
else:
_run_test(testclass, failedcases)
except Exception as ex:
log.failure(ex)
failedcases.append(testclass)
if debugger:
do()
else:
try:
do()
except Exception as ex:
log.failure(ex)
failedcases.append(testclass)
log.end_test(name)
+7 -1
View File
@@ -26,6 +26,8 @@ parser.add_argument('--artifacts', default="artifacts",
help="The folder to put output artifacts in. Will be completely cleared.", type=str)
parser.add_argument('--temp', default="tmp",
help="The folder to put temporary run data in. Will be completely cleared.", type=str)
parser.add_argument('--debugger',
help="Enable debugger mode, exceptions are not caught by the framework.", action="store_true")
# Internal command, when we fork out to run a test in a separate process
parser.add_argument('--internal_run_test', help=argparse.SUPPRESS, type=str, required=False)
# Internal command, when we re-run as admin to register vulkan layer
@@ -90,9 +92,13 @@ rdtest.set_data_dir(os.path.realpath(args.data))
rdtest.set_data_extra_dir(os.path.realpath(args.data_extra))
rdtest.set_temp_dir(os.path.realpath(args.temp))
# debugger option implies in-process test running
if args.debugger:
args.in_process = True
if args.internal_vulkan_register:
rdtest.vulkan_register()
elif args.internal_run_test is not None:
rdtest.internal_run_test(args.internal_run_test)
else:
rdtest.run_tests(args.test_include, args.test_exclude, args.in_process, args.slow_tests)
rdtest.run_tests(args.test_include, args.test_exclude, args.in_process, args.slow_tests, args.debugger)