summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/webkitpy/layout_tests/port/test_files.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Scripts/webkitpy/layout_tests/port/test_files.py')
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/port/test_files.py42
1 files changed, 12 insertions, 30 deletions
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/test_files.py b/Tools/Scripts/webkitpy/layout_tests/port/test_files.py
index 2c0a7b6..41d918f 100644
--- a/Tools/Scripts/webkitpy/layout_tests/port/test_files.py
+++ b/Tools/Scripts/webkitpy/layout_tests/port/test_files.py
@@ -34,8 +34,6 @@ list of test files is constrained to those found under the paths passed in,
i.e. calling find(["LayoutTests/fast"]) will only return files
under that directory."""
-import glob
-import os
import time
from webkitpy.common.system import logutils
@@ -58,16 +56,18 @@ def find(port, paths):
paths: a list of command line paths relative to the layout_tests_dir()
to limit the search to. 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 = os.path.join(port.layout_tests_dir(), path)
+ path = fs.join(port.layout_tests_dir(), path)
if path.find('*') > -1:
- filenames = glob.glob(path)
+ filenames = fs.glob(path)
paths_to_walk.update(filenames)
else:
paths_to_walk.add(path)
@@ -75,30 +75,12 @@ def find(port, paths):
_log.debug("Gathering tests from: %s" % port.layout_tests_dir())
paths_to_walk.add(port.layout_tests_dir())
- # Now walk all the paths passed in on the command line and get filenames
+ # 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:
- if os.path.isfile(path) and _is_test_file(path):
- test_files.add(os.path.normpath(path))
- continue
-
- for root, dirs, files in os.walk(path):
- # Don't walk skipped directories or their sub-directories.
- if os.path.basename(root) in _skipped_directories:
- del dirs[:]
- continue
- # This copy and for-in is slightly inefficient, but
- # the extra walk avoidance consistently shaves .5 seconds
- # off of total walk() time on my MacBook Pro.
- for directory in dirs[:]:
- if directory in _skipped_directories:
- dirs.remove(directory)
-
- for filename in files:
- if _is_test_file(filename):
- filename = os.path.join(root, filename)
- filename = os.path.normpath(filename)
- test_files.add(filename)
+ files = fs.files_under(path, _skipped_directories, _is_test_file)
+ test_files.update(set(files))
gather_time = time.time() - gather_start_time
_log.debug("Test gathering took %f seconds" % gather_time)
@@ -106,10 +88,10 @@ def find(port, paths):
return test_files
-def _has_supported_extension(filename):
+def _has_supported_extension(fs, filename):
"""Return true if filename is one of the file extensions we want to run a
test on."""
- extension = os.path.splitext(filename)[1]
+ extension = fs.splitext(filename)[1]
return extension in _supported_file_extensions
@@ -122,7 +104,7 @@ def _is_reference_html_file(filename):
return False
-def _is_test_file(filename):
+def _is_test_file(fs, dirname, filename):
"""Return true if the filename points to a test file."""
- return (_has_supported_extension(filename) and
+ return (_has_supported_extension(fs, filename) and
not _is_reference_html_file(filename))