launcher: Ensure that -j tests run in parallel when running forever
authorThibault Saunier <tsaunier@igalia.com>
Wed, 13 May 2020 22:25:00 +0000 (18:25 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Tue, 26 May 2020 21:19:36 +0000 (17:19 -0400)
So that you can reproduce the issue you want faster!

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/197>

validate/launcher/apps/gstcheck.py
validate/launcher/baseclasses.py

index 723dbc00bb24d19424d3bf156b36283ac2e5044a..ec5764c17c30bf6339ab84c67356dcf2a35e101d 100644 (file)
@@ -65,6 +65,7 @@ class MesonTest(Test):
         for var, val in self.child_env.items():
             if val != os.environ.get(var):
                 self.add_env_variable(var, val)
+        env["GST_VALIDATE_LOGSDIR"] = self.options.logsdir
 
         return env
 
index 4b47bc41f384002fc7b78955a717c3e4097346c3..d3877fc7ad9e4c4a0bde43a44358c0ff2f5965bc 100644 (file)
@@ -159,6 +159,16 @@ class Test(Loggable):
 
         return res
 
+    def copy(self, nth=None):
+        copied_test = copy.copy(self)
+        if nth:
+            copied_test.classname += '_it' + str(nth)
+            copied_test.options = copy.copy(self.options)
+            copied_test.options.logsdir = os.path.join(copied_test.options.logsdir, str(nth))
+            os.makedirs(copied_test.options.logsdir, exist_ok=True)
+
+        return copied_test
+
     def clean(self):
         self.kill_subprocess()
         self.message = ""
@@ -2039,9 +2049,6 @@ class _TestsLauncher(Loggable):
         if not running_tests:
             running_tests = self.tests
 
-        self.total_num_tests = len(self.all_tests)
-        printc("\nRunning %d tests..." % self.total_num_tests, color=Colors.HEADER)
-
         self.reporter.init_timer()
         alone_tests = []
         tests = []
@@ -2054,6 +2061,21 @@ class _TestsLauncher(Loggable):
         max_num_jobs = min(self.options.num_jobs, len(tests))
         jobs_running = 0
 
+        if self.options.forever and len(tests) < self.options.num_jobs and len(tests):
+            max_num_jobs = self.options.num_jobs
+            copied = []
+            i = 0
+            while (len(tests) + len(copied)) < max_num_jobs:
+                copied.append(tests[i].copy(len(copied) + 1))
+
+                i += 1
+                if i >= len(tests):
+                    i = 0
+            tests += copied
+            self.tests += copied
+
+        self.total_num_tests = len(self.all_tests)
+        printc("\nRunning %d tests..." % self.total_num_tests, color=Colors.HEADER)
         # if order of test execution doesn't matter, shuffle
         # the order to optimize cpu usage
         if self.options.shuffle: