Commit d6995eb5 authored by Florent Xicluna's avatar Florent Xicluna

Merged revisions 79497 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79497 | florent.xicluna | 2010-03-30 18:31:14 +0200 (mar, 30 mar 2010) | 2 lines

  #8263: Now regrtest.py will report a failure if it receives a KeyboardInterrupt (SIGINT).
........
parent 704ed93e
...@@ -397,6 +397,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -397,6 +397,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
skipped = [] skipped = []
resource_denieds = [] resource_denieds = []
environment_changed = [] environment_changed = []
interrupted = False
if findleaks: if findleaks:
try: try:
...@@ -451,11 +452,11 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -451,11 +452,11 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
print("== ", os.getcwd()) print("== ", os.getcwd())
alltests = findtests(testdir, stdtests, nottests) alltests = findtests(testdir, stdtests, nottests)
tests = tests or args or alltests selected = tests or args or alltests
if single: if single:
tests = tests[:1] selected = selected[:1]
try: try:
next_single_test = alltests[alltests.index(tests[0])+1] next_single_test = alltests[alltests.index(selected[0])+1]
except IndexError: except IndexError:
next_single_test = None next_single_test = None
# Remove all the tests that precede start if it's set. # Remove all the tests that precede start if it's set.
...@@ -467,7 +468,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -467,7 +468,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if randomize: if randomize:
random.seed(random_seed) random.seed(random_seed)
print("Using random seed", random_seed) print("Using random seed", random_seed)
random.shuffle(tests) random.shuffle(selected)
if trace: if trace:
import trace, tempfile import trace, tempfile
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix, tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,
...@@ -496,7 +497,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -496,7 +497,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
resource_denieds.append(test) resource_denieds.append(test)
if forever: if forever:
def test_forever(tests=list(tests)): def test_forever(tests=list(selected)):
while True: while True:
for test in tests: for test in tests:
yield test yield test
...@@ -504,15 +505,13 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -504,15 +505,13 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
return return
tests = test_forever() tests = test_forever()
else: else:
tests = iter(tests) tests = iter(selected)
if use_mp: if use_mp:
from threading import Thread from threading import Thread
from queue import Queue from queue import Queue
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from collections import deque
debug_output_pat = re.compile(r"\[\d+ refs\]$") debug_output_pat = re.compile(r"\[\d+ refs\]$")
pending = deque()
output = Queue() output = Queue()
def tests_and_args(): def tests_and_args():
for test in tests: for test in tests:
...@@ -571,6 +570,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -571,6 +570,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
raise KeyboardInterrupt # What else? raise KeyboardInterrupt # What else?
accumulate_result(test, result) accumulate_result(test, result)
except KeyboardInterrupt: except KeyboardInterrupt:
interrupted = True
pending.close() pending.close()
for worker in workers: for worker in workers:
worker.join() worker.join()
...@@ -593,8 +593,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -593,8 +593,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
print("Re-running test {} in verbose mode".format(test)) print("Re-running test {} in verbose mode".format(test))
runtest(test, True, quiet, testdir, huntrleaks, debug) runtest(test, True, quiet, testdir, huntrleaks, debug)
except KeyboardInterrupt: except KeyboardInterrupt:
# print a newline separate from the ^C interrupted = True
print()
break break
except: except:
raise raise
...@@ -612,8 +611,15 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -612,8 +611,15 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if module not in save_modules and module.startswith("test."): if module not in save_modules and module.startswith("test."):
support.unload(module) support.unload(module)
if interrupted:
# print a newline after ^C
print()
print("Test suite interrupted by signal SIGINT.")
omitted = set(selected) - set(good) - set(bad) - set(skipped)
print(count(len(omitted), "test"), "omitted:")
printlist(omitted)
if good and not quiet: if good and not quiet:
if not bad and not skipped and len(good) > 1: if not bad and not skipped and not interrupted and len(good) > 1:
print("All", end=' ') print("All", end=' ')
print(count(len(good), "test"), "OK.") print(count(len(good), "test"), "OK.")
if print_slow: if print_slow:
...@@ -678,7 +684,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -678,7 +684,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if runleaks: if runleaks:
os.system("leaks %d" % os.getpid()) os.system("leaks %d" % os.getpid())
sys.exit(len(bad) > 0) sys.exit(len(bad) > 0 or interrupted)
STDTESTS = [ STDTESTS = [
......
...@@ -963,6 +963,9 @@ Tests ...@@ -963,6 +963,9 @@ Tests
- Issue #8248: Add some tests for the bool type. Patch by Gregory Nofi. - Issue #8248: Add some tests for the bool type. Patch by Gregory Nofi.
- Issue #8263: Now regrtest.py will report a failure if it receives a
KeyboardInterrupt (SIGINT).
- Issue #8180 and #8207: Fix test_pep277 on OS X and add more tests for special - Issue #8180 and #8207: Fix test_pep277 on OS X and add more tests for special
Unicode normalization cases. Unicode normalization cases.
......
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