From 32b1ff90abc960f868e00aa1f4a784a423a3c221 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 5 Sep 2014 12:12:11 +0200 Subject: [PATCH] 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. --- Lib/test/regrtest.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 21709f7032..b48cba5734 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -475,8 +475,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, if bad: return tests = test_forever() + test_count = '' + test_count_width = 3 else: tests = iter(selected) + test_count = '/{}'.format(len(selected)) + test_count_width = len(test_count) - 1 if use_mp: try: @@ -521,8 +525,6 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, output.put((None, None, None, None)) return result = json.loads(result) - if not quiet: - stdout = test+'\n'+stdout output.put((test, stdout.rstrip(), stderr.rstrip(), result)) except BaseException: output.put((None, None, None, None)) @@ -531,6 +533,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, for worker in workers: worker.start() finished = 0 + test_index = 1 try: while finished < use_mp: test, stdout, stderr, result = output.get() @@ -547,15 +550,23 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, assert result[1] == 'KeyboardInterrupt' raise KeyboardInterrupt # What else? 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: interrupted = True pending.close() for worker in workers: worker.join() else: - for test in tests: + for test_index, test in enumerate(tests, 1): 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() if trace: # If we're tracing code coverage, then we don't exit with status -- 2.50.1