mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Issue 6024: make regrtest.py promote refleaks to test failures.
This commit is contained in:
parent
0db3cd6700
commit
0f489743ef
1 changed files with 11 additions and 1 deletions
|
@ -555,6 +555,7 @@ def runtest_inner(test, verbose, quiet, test_times,
|
||||||
else:
|
else:
|
||||||
capture_stdout = cStringIO.StringIO()
|
capture_stdout = cStringIO.StringIO()
|
||||||
|
|
||||||
|
refleak = False # True if the test leaked references.
|
||||||
try:
|
try:
|
||||||
save_stdout = sys.stdout
|
save_stdout = sys.stdout
|
||||||
try:
|
try:
|
||||||
|
@ -575,7 +576,7 @@ def runtest_inner(test, verbose, quiet, test_times,
|
||||||
if indirect_test is not None:
|
if indirect_test is not None:
|
||||||
indirect_test()
|
indirect_test()
|
||||||
if huntrleaks:
|
if huntrleaks:
|
||||||
dash_R(the_module, test, indirect_test, huntrleaks)
|
refleak = dash_R(the_module, test, indirect_test, huntrleaks)
|
||||||
test_time = time.time() - start_time
|
test_time = time.time() - start_time
|
||||||
test_times.append((test_time, test))
|
test_times.append((test_time, test))
|
||||||
finally:
|
finally:
|
||||||
|
@ -605,6 +606,8 @@ def runtest_inner(test, verbose, quiet, test_times,
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
|
if refleak:
|
||||||
|
return 0
|
||||||
# Except in verbose mode, tests should not print anything
|
# Except in verbose mode, tests should not print anything
|
||||||
if verbose or huntrleaks:
|
if verbose or huntrleaks:
|
||||||
return 1
|
return 1
|
||||||
|
@ -655,6 +658,11 @@ def cleanup_test_droppings(testname, verbose):
|
||||||
"removed: %s" % (testname, kind, name, msg))
|
"removed: %s" % (testname, kind, name, msg))
|
||||||
|
|
||||||
def dash_R(the_module, test, indirect_test, huntrleaks):
|
def dash_R(the_module, test, indirect_test, huntrleaks):
|
||||||
|
"""Run a test multiple times, looking for reference leaks.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
False if the test didn't leak references; True if we detected refleaks.
|
||||||
|
"""
|
||||||
# This code is hackish and inelegant, but it seems to do the job.
|
# This code is hackish and inelegant, but it seems to do the job.
|
||||||
import copy_reg, _abcoll, io
|
import copy_reg, _abcoll, io
|
||||||
|
|
||||||
|
@ -702,6 +710,8 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
|
||||||
refrep = open(fname, "a")
|
refrep = open(fname, "a")
|
||||||
print >> refrep, msg
|
print >> refrep, msg
|
||||||
refrep.close()
|
refrep.close()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def dash_R_cleanup(fs, ps, pic, abcs):
|
def dash_R_cleanup(fs, ps, pic, abcs):
|
||||||
import gc, copy_reg
|
import gc, copy_reg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue