validate: launcher: Use test index instead of counting test numbers
authorRamiro Polla <ramiro.polla@collabora.co.uk>
Fri, 16 Jan 2015 19:35:33 +0000 (20:35 +0100)
committerThibault Saunier <tsaunier@gnome.org>
Thu, 5 Feb 2015 14:18:38 +0000 (15:18 +0100)
Patch 1/4 to implement parallel test execution.

https://bugzilla.gnome.org/show_bug.cgi?id=743063

validate/launcher/baseclasses.py

index e1aa831..4af7877 100644 (file)
@@ -676,6 +676,8 @@ class TestsManager(Loggable):
         self.blacklisted_tests_patterns = []
         self._generators = []
         self.queue = Queue.Queue()
+        self.total_num_tests = 0
+        self.starting_test_num = 0
 
     def init(self):
         return False
@@ -792,14 +794,15 @@ class TestsManager(Loggable):
             test.kill_subprocess()
             raise
 
-    def run_tests(self, cur_test_num, total_num_tests):
-        i = cur_test_num
+    def run_tests(self, starting_test_num, total_num_tests):
+        self.total_num_tests = total_num_tests
+        self.starting_test_num = starting_test_num
+
         for test in self.tests:
-            sys.stdout.write("[%d / %d] " % (i + 1, total_num_tests))
+            self.print_test_num(test)
             test.test_start(self.queue)
             self.test_wait(test)
             res = test.test_end()
-            i += 1
             self.reporter.after_test(test)
             if res != Result.PASSED and (self.options.forever or
                                          self.options.fatal_error):
@@ -807,6 +810,10 @@ class TestsManager(Loggable):
 
         return Result.PASSED
 
+    def print_test_num(self, test):
+        cur_test_num = self.starting_test_num + self.tests.index(test) + 1
+        sys.stdout.write("[%d / %d] " % (cur_test_num, self.total_num_tests))
+
     def clean_tests(self):
         for test in self.tests:
             test.clean()