Skip to content

Commit 3daab4e

Browse files
committed
Print traceback when using GRAALPYTEST_FAIL_FAST
1 parent 2f81ab7 commit 3daab4e

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

graalpython/com.oracle.graal.python.test/src/graalpytest.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,11 @@ def dump_truffle_ast(func):
346346
pass
347347

348348

349-
class TestCase(object):
350-
fail_fast = os.environ.get(b"GRAALPYTEST_FAIL_FAST", "") == b"true"
349+
fail_fast = os.environ.get(b"GRAALPYTEST_FAIL_FAST", "") == b"true"
350+
exitting = False
351+
351352

353+
class TestCase(object):
352354
def __init__(self):
353355
self.exceptions = []
354356
self.passed = 0
@@ -412,7 +414,6 @@ def run_safely(self, func, print_immediately=False):
412414
else:
413415
return True
414416

415-
416417
def run_test(self, func):
417418
if "test_main" in str(func):
418419
pass
@@ -453,13 +454,16 @@ def do_run():
453454
do_run()
454455
else:
455456
self.failure(func, end)
456-
if TestCase.fail_fast:
457-
if verbose:
458-
print(FAIL, BOLD)
459-
print("\nFailing fast since GRAALPYTEST_FAIL_FAST is set ...")
460-
if verbose:
461-
print(ENDC)
462-
sys.exit(1)
457+
if fail_fast:
458+
global exitting
459+
if not exitting:
460+
exitting = True
461+
if verbose:
462+
print(FAIL, BOLD)
463+
print("\nFailing fast since GRAALPYTEST_FAIL_FAST is set ...")
464+
if verbose:
465+
print(ENDC)
466+
return
463467
force_serial_execution = any(name in func.__qualname__ for name in SERIAL_TESTS)
464468
if force_serial_execution:
465469
ThreadPool.shutdown()
@@ -640,6 +644,8 @@ def run(cls, items=None):
640644
if not instance.run_safely(instance.setUpClass, print_immediately=True):
641645
return instance
642646
for k, v in items:
647+
if exitting:
648+
break
643649
if k.startswith("test"):
644650
testfn = getattr(instance, k, v)
645651
if patterns:
@@ -757,6 +763,8 @@ def run(self):
757763
# some tests can modify the global scope leading to a RuntimeError: test_scope.test_nesting_plus_free_ref_to_global
758764
module_dict = dict(module.__dict__)
759765
for k, v in module_dict.items():
766+
if exitting:
767+
break
760768
if (k.startswith("Test") or k.endswith("Test") or k.endswith("Tests")) and isinstance(v, type):
761769
testcases.append(TestCase.runClass(v))
762770
else:

0 commit comments

Comments
 (0)