Commit 32b1ff90 authored by Victor Stinner's avatar Victor Stinner

regrtest: backport "[ 1/399]" progress back from Python 3

The progress bar helps a lot to analyze noisy buildbot logs, to find quickly
where errors occurred.
parent 3eb554fc
...@@ -475,8 +475,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -475,8 +475,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if bad: if bad:
return return
tests = test_forever() tests = test_forever()
test_count = ''
test_count_width = 3
else: else:
tests = iter(selected) tests = iter(selected)
test_count = '/{}'.format(len(selected))
test_count_width = len(test_count) - 1
if use_mp: if use_mp:
try: try:
...@@ -521,8 +525,6 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -521,8 +525,6 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
output.put((None, None, None, None)) output.put((None, None, None, None))
return return
result = json.loads(result) result = json.loads(result)
if not quiet:
stdout = test+'\n'+stdout
output.put((test, stdout.rstrip(), stderr.rstrip(), result)) output.put((test, stdout.rstrip(), stderr.rstrip(), result))
except BaseException: except BaseException:
output.put((None, None, None, None)) output.put((None, None, None, None))
...@@ -531,6 +533,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -531,6 +533,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
for worker in workers: for worker in workers:
worker.start() worker.start()
finished = 0 finished = 0
test_index = 1
try: try:
while finished < use_mp: while finished < use_mp:
test, stdout, stderr, result = output.get() test, stdout, stderr, result = output.get()
...@@ -547,15 +550,23 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, ...@@ -547,15 +550,23 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
assert result[1] == 'KeyboardInterrupt' assert result[1] == 'KeyboardInterrupt'
raise KeyboardInterrupt # What else? raise KeyboardInterrupt # What else?
accumulate_result(test, result) accumulate_result(test, result)
if not quiet:
fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}"
print(fmt.format(
test_count_width, test_index, test_count,
len(bad), test))
test_index += 1
except KeyboardInterrupt: except KeyboardInterrupt:
interrupted = True interrupted = True
pending.close() pending.close()
for worker in workers: for worker in workers:
worker.join() worker.join()
else: else:
for test in tests: for test_index, test in enumerate(tests, 1):
if not quiet: if not quiet:
print test fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}"
print(fmt.format(
test_count_width, test_index, test_count, len(bad), test))
sys.stdout.flush() sys.stdout.flush()
if trace: if trace:
# If we're tracing code coverage, then we don't exit with status # If we're tracing code coverage, then we don't exit with status
......
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