Bug 1149670 - Add support for filtering reftest manifests by path-based test selections in mozharness.;r=ahal
authorChris Manchester <cmanchester@mozilla.com>
Wed, 13 May 2015 14:08:39 -0700 (2015-05-13)
changeset 4003 e106a1a0d1610655038f4b93e3a9fa4eb37f327e
parent 4002 49f913fc2fb716cc569a173a93903e1910c159df
child 4006 1a2600cf03fc4e296b968161b34b3ae9aff09fe2
child 4007 fe62730fafaa37c800e225416d0ff1e2ac44be2e
push id3173
push usercmanchester@mozilla.com
push dateWed, 13 May 2015 21:08:46 +0000 (2015-05-13)
reviewersahal
bugs1149670
Bug 1149670 - Add support for filtering reftest manifests by path-based test selections in mozharness.;r=ahal
mozharness/mozilla/testing/try_tools.py
--- a/mozharness/mozilla/testing/try_tools.py
+++ b/mozharness/mozilla/testing/try_tools.py
@@ -78,58 +78,80 @@ class TryToolsMixin(object):
                     out_args.append('%s=%s' % (label, value))
 
         self.harness_extra_args = out_args
 
     def _resolve_specified_manifests(self):
         if not self.try_test_paths:
             return None
 
+        target_manifests = set(self.try_test_paths)
+
+        def filter_ini_manifest(line):
+            # Lines are formatted as [include:<path>], we care about <path>.
+            parts = line.split(':')
+            term = line
+            if len(parts) == 2:
+                term = parts[1]
+            if term.endswith(']'):
+                term = term[:-1]
+            if (term in target_manifests or
+                any(term.startswith(l) for l in target_manifests)):
+                return True
+            return False
+
+        def filter_list_manifest(line):
+            # Lines are usually formatted as "include <path>", we care about <path>.
+            parts = line.split()
+            term = line
+            if len(parts) == 2:
+                term = parts[1]
+            # Reftest master manifests also include skip-if lines and relative
+            # paths we aren't doing to resolve here, so unlike above this is just
+            # a substring check.
+            if (term in target_manifests or
+                any(l in term for l in target_manifests)):
+                return True
+            return False
+
         # The master manifests we need to filter for target manifests.
         # TODO: All this needs to go in a config file somewhere and get sewn
         # into the job definition so its less likely to break as things are
         # modified. One straightforward way to achieve this would be with a key
         # in the tree manifest for the master manifest path, however the current
         # tree manifests don't distinguish between flavors of mochitests to this
         # isn't straightforward.
         master_manifests = [
-            'mochitest/chrome/chrome.ini',
-            'mochitest/browser/browser-chrome.ini',
-            'mochitest/tests/mochitest.ini',
-            'xpcshell/tests/all-test-dirs.list',
-            'xpcshell/tests/xpcshell.ini',
+            ('mochitest/chrome/chrome.ini', filter_ini_manifest),
+            ('mochitest/browser/browser-chrome.ini', filter_ini_manifest),
+            ('mochitest/tests/mochitest.ini', filter_ini_manifest),
+            ('xpcshell/tests/all-test-dirs.list', filter_ini_manifest),
+            ('xpcshell/tests/xpcshell.ini', filter_ini_manifest),
+            ('reftest/tests/layout/reftests/reftest.list', filter_list_manifest),
+            ('reftest/tests/testing/crashtest/crashtests.list', filter_list_manifest),
         ]
 
         dirs = self.query_abs_dirs()
         tests_dir = dirs.get('abs_test_install_dir',
                              os.path.join(dirs['abs_work_dir'], 'tests'))
-        master_manifests = [os.path.join(tests_dir, name) for name in master_manifests]
-        target_manifests = set(self.try_test_paths)
-        for m in master_manifests:
+        master_manifests = [(os.path.join(tests_dir, name), filter_fn) for (name, filter_fn) in
+                            master_manifests]
+        for m, filter_fn in master_manifests:
             if not os.path.isfile(m):
                 continue
 
             self.info("Filtering master manifest at: %s" % m)
             lines = self.read_from_file(m).splitlines()
-            out_lines = []
-            for line in lines:
-                # Lines are formatted as [include:<path>], we care about <path>.
-                parts = line.split(':')
-                term = line
-                if len(parts) == 2:
-                    term = parts[1]
-                if term.endswith(']'):
-                    term = term[:-1]
-                if term in target_manifests:
-                    out_lines.append(line)
-                elif any(term.startswith(l) for l in target_manifests):
-                    out_lines.append(line)
-            os.remove(m)
+
+            out_lines = [line for line in lines if filter_fn(line)]
+
+            self.rmtree(m)
             self.write_to_file(m, '\n'.join(out_lines))
 
+
     def append_harness_extra_args(self, cmd):
         """Append arguments derived from try syntax to a command."""
         # TODO: Detect and reject incompatible arguments
         extra_args = self.harness_extra_args[:] if self.harness_extra_args else []
         if self.try_test_paths:
             self._resolve_specified_manifests()
             self.info('TinderboxPrint: Tests will be run from the following '
                       'manifests: %s.' % ','.join(self.try_test_paths))