diff options
author | dpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 00:43:29 +0000 |
---|---|---|
committer | dpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 00:43:29 +0000 |
commit | d38c8cb35e8c9860981e2df77a98a43b32c9df8f (patch) | |
tree | ed0c0be5e654567e79160f317163576162cb2418 /webkit/tools/layout_tests/layout_package | |
parent | 3e10e93146c326ab1368452dfdc84fb5d5165d33 (diff) | |
download | chromium_src-d38c8cb35e8c9860981e2df77a98a43b32c9df8f.zip chromium_src-d38c8cb35e8c9860981e2df77a98a43b32c9df8f.tar.gz chromium_src-d38c8cb35e8c9860981e2df77a98a43b32c9df8f.tar.bz2 |
Refactor run_webkit_tests a bit so we can extract the list of test files
separate for the layout test task force reporting. We can now build out the
full expecatations list by calling functions in layout_package/test_files
and layout_package/test_expectations (previously you needed to call private
routines in run_webkit_tests).
BUG=none
TEST=none
R=ojan@chromium.org
Review URL: http://codereview.chromium.org/254011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/layout_tests/layout_package')
-rw-r--r-- | webkit/tools/layout_tests/layout_package/test_files.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/webkit/tools/layout_tests/layout_package/test_files.py b/webkit/tools/layout_tests/layout_package/test_files.py new file mode 100644 index 0000000..45c0dc4 --- /dev/null +++ b/webkit/tools/layout_tests/layout_package/test_files.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""This module is used to find all of the layout test files used by Chromium +(across all platforms). It exposes one public function - GatherTestFiles() - +which takes an optional list of paths. If a list is passed in, the returned +list of test files is constrained to those found under the paths passed in, +i.e. calling GatherTestFiles(["LayoutTests/fast"]) will only return files +under that directory.""" + +import os +import path_utils + +# When collecting test cases, we include any file with these extensions. +_supported_file_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', + '.php', '.svg']) +# When collecting test cases, skip these directories +_skipped_directories = set(['.svn', '_svn', 'resources', 'script-tests']) + +# Top-level directories to shard when running tests. +SHARDABLE_DIRECTORIES = set(['chrome', 'LayoutTests', 'pending']) + +def GatherTestFiles(paths): + """Generate a set of test files and return them. + + Args: + paths: a list of command line paths relative to the webkit/tests + directory. glob patterns are ok. + """ + paths_to_walk = set() + # if paths is empty, provide a pre-defined list. + if not paths: + paths = SHARDABLE_DIRECTORIES + for path in paths: + # If there's an * in the name, assume it's a glob pattern. + path = os.path.join(path_utils.LayoutTestsDir(path), path) + if path.find('*') > -1: + filenames = glob.glob(path) + paths_to_walk.update(filenames) + else: + paths_to_walk.add(path) + + # Now walk all the paths passed in on the command line and get filenames + test_files = set() + for path in paths_to_walk: + if os.path.isfile(path) and _HasSupportedExtension(path): + test_files.add(os.path.normpath(path)) + continue + + for root, dirs, files in os.walk(path): + # don't walk skipped directories and sub directories + if os.path.basename(root) in _skipped_directories: + del dirs[:] + continue + + for filename in files: + if _HasSupportedExtension(filename): + filename = os.path.join(root, filename) + filename = os.path.normpath(filename) + test_files.add(filename) + + return test_files + +def _HasSupportedExtension(filename): + """Return true if filename is one of the file extensions we want to run a + test on.""" + extension = os.path.splitext(filename)[1] + return extension in _supported_file_extensions + |