Bug 1317970 - Filter python unittests through manifestparser.active_tests, r?chmanchester draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 17 Nov 2016 16:30:27 -0500
changeset 442119 9706802e9884f7edaff533b3d2fe75ae91e24ab4
parent 442118 1136b8ed2306ec1fc4c8588549f9bc8d040fbe65
child 537701 500051de03b2d9474f94a187a14165e8d701a620
push id36588
push userahalberstadt@mozilla.com
push dateMon, 21 Nov 2016 19:39:30 +0000
reviewerschmanchester
bugs1317970
milestone53.0a1
Bug 1317970 - Filter python unittests through manifestparser.active_tests, r?chmanchester The build system's TestResolver does a pretty good job of getting the right manifestparser based tests to run, but it isn't perfect. Notably, it ignores the 'disabled' key. We filter the tests through manifestparser here to make sure the build system didn't miss anything. For context, this is also what the other test harnesses (e.g mochitest) do as well. MozReview-Commit-ID: FaHb4nvuoK9
python/mach_commands.py
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -10,16 +10,19 @@ import mozpack.path as mozpath
 import os
 
 from concurrent.futures import (
     ThreadPoolExecutor,
     as_completed,
     thread,
 )
 
+import mozinfo
+from manifestparser import TestManifest
+
 from mozbuild.base import (
     MachCommandBase,
 )
 
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
@@ -123,24 +126,28 @@ class MachCommands(MachCommandBase):
 
         if not test_objects:
             message = 'TEST-UNEXPECTED-FAIL | No tests collected'
             if not path_only:
                 message += ' (Not in PYTHON_UNITTEST_MANIFESTS? Try --path-only?)'
             self.log(logging.WARN, 'python-test', {}, message)
             return 1
 
+        mp = TestManifest()
+        mp.tests.extend(test_objects)
+        tests = mp.active_tests(disabled=False, **mozinfo.info)
+
         self.jobs = jobs
         self.terminate = False
         self.verbose = verbose
 
         return_code = 0
         with ThreadPoolExecutor(max_workers=self.jobs) as executor:
             futures = [executor.submit(self._run_python_test, test['path'])
-                       for test in test_objects]
+                       for test in tests]
 
             try:
                 for future in as_completed(futures):
                     output, ret = future.result()
 
                     for line in output:
                         self.log(logging.INFO, 'python-test', {'line': line.rstrip()}, '{line}')