Commit 2cf17f19 authored by Stefan Behnel's avatar Stefan Behnel

Enable faulthandler around the test runs to get a notice on shard crashes.

parent f61e759d
......@@ -2501,7 +2501,33 @@ def runtests(options, cmd_args, coverage=None):
except AttributeError:
pass # not available on PyPy
result = test_runner.run(test_suite)
enable_faulthandler = False
try:
import faulthandler
except ImportError:
pass
else:
enable_faulthandler = not faulthandler.is_enabled()
if enable_faulthandler:
faulthandler.enable()
# Run the collected tests.
try:
if options.shard_num > -1:
sys.stderr.write("Tests in shard %d starting" % options.shard_num)
result = test_runner.run(test_suite)
except Exception as exc:
# Make sure we print exceptions also from shards.
if options.shard_num > -1:
sys.stderr.write("Tests in shard %d crashed: %s" % (options.shard_num, exc))
import traceback
traceback.print_exc()
finally:
if enable_faulthandler:
faulthandler.disable()
if options.shard_num > -1:
sys.stderr.write("Tests in shard %d terminated (%s)" % (
options.shard_num, sys.exc_info()[1] or "no crash"))
if common_utility_dir and options.shard_num < 0 and options.cleanup_workdir:
shutil.rmtree(common_utility_dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment