From d38c8cb35e8c9860981e2df77a98a43b32c9df8f Mon Sep 17 00:00:00 2001 From: "dpranke@google.com" Date: Wed, 30 Sep 2009 00:43:29 +0000 Subject: 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 --- .../layout_tests/layout_package/test_files.py | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 webkit/tools/layout_tests/layout_package/test_files.py (limited to 'webkit/tools/layout_tests/layout_package') 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 + -- cgit v1.1