Bug 1158019 - Only resolve to tests under a subdirectory if an input to mozbuild's test resolver is the prefix of a directory containing tests. r=gps

Formerly, running |./mach test image/| would result in running a number of devtools tests
in addition to running tests under the image/ subdirectory. With this change, only tests
under the image/ directory would be run. Note that ./mach test animations or similar will
still run a variety of tests across the tree, because this input does not match a directory.
This commit is contained in:
Chris Manchester 2015-04-24 17:14:03 -07:00
parent 6330d6fde9
commit 2c43b3d747

View File

@ -80,8 +80,9 @@ class TestMetadata(object):
``paths`` can be an iterable of values to use to identify tests to run.
If an entry is a known test file, tests associated with that file are
returned (there may be multiple configurations for a single file). If
an entry is a directory, all tests in that directory are returned. If
the string appears in a known test file, that test file is considered.
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.
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
@ -123,8 +124,10 @@ class TestMetadata(object):
candidate_paths |= set(self._tests_by_path.keys())
continue
# If the path is a directory, pull in all tests in that directory.
if path in self._test_dirs:
# 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
any(p.startswith(path) for p in self._tests_by_path)):
candidate_paths |= {p for p in self._tests_by_path
if p.startswith(path)}
continue