Commit b3fa3005 authored by Stefan Behnel's avatar Stefan Behnel

try to make test runner more robust

parent d66375b2
......@@ -891,9 +891,10 @@ def run_forked_test(result, run_func, test_name, fork=True):
child_id = os.fork()
if not child_id:
result_code = 0
output = None
try:
try:
tests = None
tests = partial_result = None
try:
partial_result = PartialTestResult(result)
run_func(partial_result)
......@@ -901,6 +902,8 @@ def run_forked_test(result, run_func, test_name, fork=True):
sys.stderr.flush()
gc.collect()
except Exception:
result_code = 1
if partial_result is not None:
if tests is None:
# importing failed, try to fake a test class
tests = _FakeClass(
......@@ -908,14 +911,20 @@ def run_forked_test(result, run_func, test_name, fork=True):
_shortDescription=test_name,
module_name=None)
partial_result.addError(tests, sys.exc_info())
result_code = 1
output = open(result_file, 'wb')
pickle.dump(partial_result.data(), output)
except:
traceback.print_exc()
finally:
try: output.close()
try: sys.stderr.flush()
except: pass
try: sys.stdout.flush()
except: pass
try:
if output is not None:
output.close()
except:
pass
os._exit(result_code)
try:
......
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