Bug 1293259 - [manifestparser] Add ability to match wildcards in "pathprefix" filter draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 15 Nov 2016 09:41:20 -0500
changeset 439174 4076bc52c2c4a9d818406e258363fd36a8a2708e
parent 439146 fb3473c1770d3dace1ec09dfbb574fabe7cb26b1
child 439175 e72bf547fe85f9df684ec4edab1f2001ab2989d9
push id35923
push userahalberstadt@mozilla.com
push dateTue, 15 Nov 2016 15:06:20 +0000
bugs1293259
milestone53.0a1
Bug 1293259 - [manifestparser] Add ability to match wildcards in "pathprefix" filter MozReview-Commit-ID: DKyhwQjamUA
testing/mozbase/manifestparser/manifestparser/filters.py
--- a/testing/mozbase/manifestparser/manifestparser/filters.py
+++ b/testing/mozbase/manifestparser/manifestparser/filters.py
@@ -7,16 +7,18 @@ A filter is a callable that accepts an i
 dictionary of values, and returns a new iterable of test objects. It is
 possible to define custom filters if the built-in ones are not enough.
 """
 
 from collections import defaultdict, MutableSequence
 import itertools
 import os
 
+import mozpack.path as mozpath
+
 from .expression import (
     parse,
     ParseError,
 )
 
 
 # built-in filters
 
@@ -351,28 +353,30 @@ class pathprefix(InstanceFilter):
         InstanceFilter.__init__(self, paths)
         if isinstance(paths, basestring):
             paths = [paths]
         self.paths = paths
 
     def __call__(self, tests, values):
         for test in tests:
             for tp in self.paths:
-                tp = os.path.normpath(tp)
+                tp = mozpath.normpath(tp)
 
-                path = test['relpath']
+                path = mozpath.normpath(test['relpath'])
                 if os.path.isabs(tp):
-                    path = test['path']
+                    path = mozpath.normpath(test['path'])
 
-                if not os.path.normpath(path).startswith(tp):
+                if '*' in tp and not mozpath.match(path, tp):
+                    continue
+                elif not os.path.normpath(path).startswith(tp):
                     continue
 
                 # any test path that points to a single file will be run no
                 # matter what, even if it's disabled
-                if 'disabled' in test and os.path.normpath(test['relpath']) == tp:
+                if 'disabled' in test and path == tp:
                     del test['disabled']
                 yield test
                 break
 
 
 # filter container
 
 DEFAULT_FILTERS = (