_skipped_directories = set(['.svn', '_svn', 'resources', 'script-tests'])
-def find(port, paths):
- """Finds the set of tests under port.layout_tests_dir().
+def find(port, paths=None):
+ """Finds the set of tests under a given list of sub-paths.
Args:
- paths: a list of command line paths relative to the layout_tests_dir()
- to limit the search to. glob patterns are ok.
+ paths: a list of path expressions relative to port.layout_tests_dir()
+ to search. Glob patterns are ok, as are path expressions with
+ forward slashes on Windows. If paths is empty, we look at
+ everything under the layout_tests_dir().
+ """
+ paths = paths or ['*']
+ filesystem = port._filesystem
+ return normalized_find(filesystem, normalize(filesystem, port.layout_tests_dir(), paths))
+
+
+def normalize(filesystem, base_dir, paths):
+ return [filesystem.normpath(filesystem.join(base_dir, path)) for path in paths]
+
+
+def normalized_find(filesystem, paths):
+ """Finds the set of tests under the list of paths.
+
+ Args:
+ paths: a list of absolute path expressions to search.
+ Glob patterns are ok.
"""
- fs = port._filesystem
gather_start_time = time.time()
paths_to_walk = set()
- # if paths is empty, provide a pre-defined list.
- if paths:
- _log.debug("Gathering tests from: %s relative to %s" % (paths, port.layout_tests_dir()))
- for path in paths:
- # If there's an * in the name, assume it's a glob pattern.
- path = fs.join(port.layout_tests_dir(), path)
- if path.find('*') > -1:
- filenames = fs.glob(path)
- paths_to_walk.update(filenames)
- else:
- paths_to_walk.add(path)
- else:
- _log.debug("Gathering tests from: %s" % port.layout_tests_dir())
- paths_to_walk.add(port.layout_tests_dir())
+ for path in paths:
+ # If there's an * in the name, assume it's a glob pattern.
+ if path.find('*') > -1:
+ filenames = filesystem.glob(path)
+ paths_to_walk.update(filenames)
+ else:
+ paths_to_walk.add(path)
# FIXME: I'm not sure there's much point in this being a set. A list would
# probably be faster.
test_files = set()
for path in paths_to_walk:
- files = fs.files_under(path, _skipped_directories, _is_test_file)
+ files = filesystem.files_under(path, _skipped_directories, _is_test_file)
test_files.update(set(files))
gather_time = time.time() - gather_start_time
return test_files
-def _has_supported_extension(fs, filename):
+def _has_supported_extension(filesystem, filename):
"""Return true if filename is one of the file extensions we want to run a
test on."""
- extension = fs.splitext(filename)[1]
+ extension = filesystem.splitext(filename)[1]
return extension in _supported_file_extensions
return False
-def _is_test_file(fs, dirname, filename):
+def _is_test_file(filesystem, dirname, filename):
"""Return true if the filename points to a test file."""
- return (_has_supported_extension(fs, filename) and
+ return (_has_supported_extension(filesystem, filename) and
not _is_reference_html_file(filename))