summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2019-01-19 16:14:08 +0100
committerStefan Behnel <stefan_ml@behnel.de>2019-01-19 16:14:08 +0100
commit109630f3bb1688719ee024dbfd30b2cfe9d52d2c (patch)
treebcf5eafb695cf3b2975da2c823b5af27cf348f6d
parent2722c00f7dea0e450209c964a65d77d9bb775d43 (diff)
parentc3be8ff4a9cd8ed067d08db83a03d1d609b4567b (diff)
downloadcython-109630f3bb1688719ee024dbfd30b2cfe9d52d2c.tar.gz
Merge branch '0.29.x'
-rwxr-xr-xruntests.py31
-rw-r--r--tests/run/sequential_parallel.pyx2
2 files changed, 16 insertions, 17 deletions
diff --git a/runtests.py b/runtests.py
index e72255721..f168cb194 100755
--- a/runtests.py
+++ b/runtests.py
@@ -1309,7 +1309,6 @@ 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 = partial_result = None
@@ -1329,8 +1328,9 @@ def run_forked_test(result, run_func, test_name, fork=True):
_shortDescription=test_name,
module_name=None)
partial_result.addError(tests, sys.exc_info())
- output = open(result_file, 'wb')
- pickle.dump(partial_result.data(), output)
+ if partial_result is not None:
+ with open(result_file, 'wb') as output:
+ pickle.dump(partial_result.data(), output)
except:
traceback.print_exc()
finally:
@@ -1338,11 +1338,6 @@ def run_forked_test(result, run_func, test_name, fork=True):
except: pass
try: sys.stdout.flush()
except: pass
- try:
- if output is not None:
- output.close()
- except:
- pass
os._exit(result_code)
try:
@@ -1352,18 +1347,22 @@ def run_forked_test(result, run_func, test_name, fork=True):
# upper byte of result_code, and the signal it was
# killed by in the lower byte
if result_code & 255:
- raise Exception("Tests in module '%s' were unexpectedly killed by signal %d"%
- (module_name, result_code & 255))
+ raise Exception(
+ "Tests in module '%s' were unexpectedly killed by signal %d, see test output for details." % (
+ module_name, result_code & 255))
result_code >>= 8
if result_code in (0,1):
- input = open(result_file, 'rb')
try:
- PartialTestResult.join_results(result, pickle.load(input))
- finally:
- input.close()
+ with open(result_file, 'rb') as f:
+ PartialTestResult.join_results(result, pickle.load(f))
+ except Exception:
+ raise Exception(
+ "Failed to load test result from test in module '%s' after exit status %d,"
+ " see test output for details." % (module_name, result_code))
if result_code:
- raise Exception("Tests in module '%s' exited with status %d" %
- (module_name, result_code))
+ raise Exception(
+ "Tests in module '%s' exited with status %d, see test output for details." % (
+ module_name, result_code))
finally:
try:
os.unlink(result_file)
diff --git a/tests/run/sequential_parallel.pyx b/tests/run/sequential_parallel.pyx
index 64e8233bd..415d0bdc7 100644
--- a/tests/run/sequential_parallel.pyx
+++ b/tests/run/sequential_parallel.pyx
@@ -60,7 +60,7 @@ def test_prange_matches_range(int start, int stop, int step):
>>> test_prange_matches_range(2, -10, -3)
>>> test_prange_matches_range(3, -10, -3)
"""
- cdef int i, range_last, prange_last
+ cdef int i = -765432, range_last = -876543, prange_last = -987654
prange_set = set()
for i in prange(start, stop, step, nogil=True, num_threads=3):
prange_last = i