[Python-checkins] r83543 - python/branches/py3k/Lib/test/regrtest.py

georg.brandl python-checkins at python.org
Mon Aug 2 20:59:52 CEST 2010


Author: georg.brandl
Date: Mon Aug  2 20:59:52 2010
New Revision: 83543

Log:
#8560: add progress indicator to regrtest.

Modified:
   python/branches/py3k/Lib/test/regrtest.py

Modified: python/branches/py3k/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k/Lib/test/regrtest.py	(original)
+++ python/branches/py3k/Lib/test/regrtest.py	Mon Aug  2 20:59:52 2010
@@ -390,7 +390,7 @@
             sys.exit(0)
         else:
             print(("No handler for option {}.  Please report this as a bug "
-                  "at http://bugs.python.org.").format(o), file=sys.stderr)
+                   "at http://bugs.python.org.").format(o), file=sys.stderr)
             sys.exit(1)
     if single and fromfile:
         usage("-s and -f don't go together!")
@@ -517,6 +517,9 @@
     else:
         tests = iter(selected)
 
+    tests = list(tests)
+    test_count = len(tests)
+    test_count_width = len(str(test_count))
     if use_mp:
         try:
             from threading import Thread
@@ -559,8 +562,6 @@
                         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))
@@ -569,12 +570,16 @@
         for worker in workers:
             worker.start()
         finished = 0
+        test_index = 1
         try:
             while finished < use_mp:
                 test, stdout, stderr, result = output.get()
                 if test is None:
                     finished += 1
                     continue
+                if not quiet:
+                    print("[{1:{0}}/{2:{0}}] {3}".format(
+                        test_count_width, test_index, test_count, test))
                 if stdout:
                     print(stdout)
                 if stderr:
@@ -583,15 +588,17 @@
                     assert result[1] == 'KeyboardInterrupt'
                     raise KeyboardInterrupt   # What else?
                 accumulate_result(test, result)
+                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)
+                print("[{1:{0}}/{2:{0}}] {3}".format(
+                    test_count_width, test_index, test_count, test))
                 sys.stdout.flush()
             if trace:
                 # If we're tracing code coverage, then we don't exit with status


More information about the Python-checkins mailing list