Bug 1048446 - [python-test] Add 'sequential' key to python.ini manifests so tests can opt out of running in parallel, r?jmaher draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 01 Jun 2017 09:50:15 -0400
changeset 591742 4d5d91d49bc1b1f986a145866df049774fcd7ce4
parent 591741 83ad9475ab0e994fd363846e6e1dee27781b49bc
child 591743 3c9703d47928a5f30ea1d9925d3ffa2881ed6273
push id63159
push userahalberstadt@mozilla.com
push dateFri, 09 Jun 2017 15:00:30 +0000
reviewersjmaher
bugs1048446
milestone55.0a1
Bug 1048446 - [python-test] Add 'sequential' key to python.ini manifests so tests can opt out of running in parallel, r?jmaher MozReview-Commit-ID: DQWJDdU9QHO
python/mach_commands.py
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -133,44 +133,60 @@ class MachCommands(MachCommandBase):
 
         filters = []
         if subsuite == 'default':
             filters.append(mpf.subsuite(None))
         elif subsuite:
             filters.append(mpf.subsuite(subsuite))
 
         tests = mp.active_tests(filters=filters, disabled=False, **mozinfo.info)
+        parallel = []
+        sequential = []
+        for test in tests:
+            if test.get('sequential'):
+                sequential.append(test)
+            else:
+                parallel.append(test)
 
         self.jobs = jobs
         self.terminate = False
         self.verbose = verbose
 
         return_code = 0
+
+        def on_test_finished(result):
+            output, ret, test_path = result
+
+            for line in output:
+                self.log(logging.INFO, 'python-test', {'line': line.rstrip()}, '{line}')
+
+            if ret and not return_code:
+                self.log(logging.ERROR, 'python-test', {'test_path': test_path, 'ret': ret},
+                         'Setting retcode to {ret} from {test_path}')
+            return return_code or ret
+
         with ThreadPoolExecutor(max_workers=self.jobs) as executor:
             futures = [executor.submit(self._run_python_test, test['path'])
-                       for test in tests]
+                       for test in parallel]
 
             try:
                 for future in as_completed(futures):
-                    output, ret, test_path = future.result()
-
-                    for line in output:
-                        self.log(logging.INFO, 'python-test', {'line': line.rstrip()}, '{line}')
-
-                    if ret and not return_code:
-                        self.log(logging.ERROR, 'python-test', {'test_path': test_path, 'ret': ret}, 'Setting retcode to {ret} from {test_path}')
-                    return_code = return_code or ret
+                    return_code = on_test_finished(future.result())
             except KeyboardInterrupt:
                 # Hack to force stop currently running threads.
                 # https://gist.github.com/clchiou/f2608cbe54403edb0b13
                 executor._threads.clear()
                 thread._threads_queues.clear()
                 raise
 
-        self.log(logging.INFO, 'python-test', {'return_code': return_code}, 'Return code from mach python-test: {return_code}')
+        for test in sequential:
+            return_code = on_test_finished(self._run_python_test(test['path']))
+
+        self.log(logging.INFO, 'python-test', {'return_code': return_code},
+                 'Return code from mach python-test: {return_code}')
         return return_code
 
     def _run_python_test(self, test_path):
         from mozprocess import ProcessHandler
 
         output = []
 
         def _log(line):