Bug 1293259 - [manifestparser] Add ability to match wildcards in "pathprefix" filter
MozReview-Commit-ID: DKyhwQjamUA
--- 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 = (