changeset 21438:f647287b44d1

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 13:00:40 -0700
parents d9532be2fc4d
children 2e22954b97e3
files tests/run-tests.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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: