run-tests: pass an optional TestResult into _executetests()
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 20 Apr 2014 13:00:40 -0700
changeset 21438 f647287b44d1
parent 21437 d9532be2fc4d
child 21439 2e22954b97e3
run-tests: pass an optional TestResult into _executetests() If the result is passed, we execute tests in the unittest way. A subsequent patch will actually do this.
tests/run-tests.py
--- a/tests/run-tests.py	Sun Apr 20 12:49:43 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 13:00:40 2014 -0700
@@ -1076,6 +1076,7 @@
             '~': [],
             's': [],
             'i': [],
+            'u': [],
         }
         self.abort = [False]
         self._createdfiles = []
@@ -1534,14 +1535,24 @@
                 os.mkdir(adir)
             covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit)
 
-    def _executetests(self, tests):
+    def _executetests(self, tests, result=None):
+        # We copy because we modify the list.
+        tests = list(tests)
+
         jobs = self.options.jobs
         done = queue.Queue()
         running = 0
 
-        def job(test):
+        def job(test, result):
             try:
-                done.put(test.run())
+                # If in unittest mode.
+                if result:
+                    test(result)
+                    # We need to put something here to make the logic happy.
+                    # This will get cleaned up later.
+                    done.put(('u', None, None))
+                else:
+                    done.put(test.run())
                 test.cleanup()
             except KeyboardInterrupt:
                 pass
@@ -1565,7 +1576,7 @@
                     if self.options.loop:
                         tests.append(test)
                     t = threading.Thread(target=job, name=test.name,
-                                         args=[test])
+                                         args=(test, result))
                     t.start()
                     running += 1
         except KeyboardInterrupt: