Bug 1184405 - Take matches by wildcard pattern into account in the test resolver. r=gps

--HG--
extra : commitid : 20bUC0s5hyx
This commit is contained in:
Chris Manchester 2015-09-25 07:33:11 -07:00
Родитель c5c1b11a93
Коммит 933886fcaf
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -288,6 +288,22 @@ class TestTestResolver(Base):
self.assertEqual(len(tests), 1)
self.assertEqual(tests[0]['name'], 'src/common/TestAndroidLogWriters.java')
def test_wildcard_patterns(self):
"""Test matching paths by wildcard."""
r = self._get_resolver()
tests = list(r.resolve_tests(paths=['mobile/**']))
self.assertEqual(len(tests), 2)
for t in tests:
self.assertTrue(t['file_relpath'].startswith('mobile'))
tests = list(r.resolve_tests(paths=['**/**.js', 'accessible/**']))
self.assertEqual(len(tests), 7)
for t in tests:
path = t['file_relpath']
self.assertTrue(path.startswith('accessible') or path.endswith('.js'))
if __name__ == '__main__':
main()

Просмотреть файл

@ -83,7 +83,8 @@ class TestMetadata(object):
returned (there may be multiple configurations for a single file). If
an entry is a directory, or a prefix of a directory containing tests,
all tests in that directory are returned. If the string appears in a
known test file, that test file is considered.
known test file, that test file is considered. If the path contains
a wildcard pattern, tests matching that pattern are returned.
If ``under_path`` is a string, it will be used to filter out tests that
aren't in the specified path prefix relative to topsrcdir or the
@ -134,6 +135,11 @@ class TestMetadata(object):
candidate_paths |= set(self._tests_by_path.keys())
continue
if '*' in path:
candidate_paths |= {p for p in self._tests_by_path
if mozpath.match(p, path)}
continue
# If the path is a directory, or the path is a prefix of a directory
# containing tests, pull in all tests in that directory.
if (path in self._test_dirs or