Title: [284595] trunk/Tools
Revision
284595
Author
[email protected]
Date
2021-10-21 02:48:26 -0700 (Thu, 21 Oct 2021)

Log Message

Move layout_test_finder to layout_test_finder_legacy
https://bugs.webkit.org/show_bug.cgi?id=232018

Reviewed by Darin Adler.

This is a simple rename; no further changes.

* Scripts/open-layout-test:
* Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py: Renamed from Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py.
(_is_reference_html_file):
(_has_supported_extension):
(LayoutTestFinder):
(LayoutTestFinder.__init__):
(LayoutTestFinder.find_tests):
(LayoutTestFinder.find_tests_by_path):
(LayoutTestFinder._expanded_paths):
(LayoutTestFinder._real_tests):
(LayoutTestFinder._is_test_file):
(LayoutTestFinder._is_w3c_resource_file):
(LayoutTestFinder._strip_test_dir_prefixes):
(LayoutTestFinder._strip_test_dir_prefix):
(LayoutTestFinder._read_test_names_from_file):
(LayoutTestFinder._strip_comments):
* Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py: Renamed from Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py.
(MockLayoutTestFinder):
(MockLayoutTestFinder._real_tests):
(LayoutTestFinderTests):
(LayoutTestFinderTests.make_finder):
(LayoutTestFinderTests.test_supported_test_extensions):
(LayoutTestFinderTests.test_is_reference_html_file):
(LayoutTestFinderTests.test_find_no_paths_specified):
(LayoutTestFinderTests.test_find_one_test):
(LayoutTestFinderTests.test_find_glob):
(LayoutTestFinderTests.test_find_with_skipped_directories):
(LayoutTestFinderTests.test_find_with_skipped_directories_2):
(LayoutTestFinderTests.test_is_test_file):
(LayoutTestFinderTests.test_is_w3c_resource_file):
* Scripts/webkitpy/layout_tests/controllers/manager.py:
* Scripts/webkitpy/tool/commands/queries.py:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (284594 => 284595)


--- trunk/Tools/ChangeLog	2021-10-21 08:46:22 UTC (rev 284594)
+++ trunk/Tools/ChangeLog	2021-10-21 09:48:26 UTC (rev 284595)
@@ -1,3 +1,45 @@
+2021-10-21  Sam Sneddon  <[email protected]>
+
+        Move layout_test_finder to layout_test_finder_legacy
+        https://bugs.webkit.org/show_bug.cgi?id=232018
+
+        Reviewed by Darin Adler.
+
+        This is a simple rename; no further changes.
+
+        * Scripts/open-layout-test:
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py: Renamed from Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py.
+        (_is_reference_html_file):
+        (_has_supported_extension):
+        (LayoutTestFinder):
+        (LayoutTestFinder.__init__):
+        (LayoutTestFinder.find_tests):
+        (LayoutTestFinder.find_tests_by_path):
+        (LayoutTestFinder._expanded_paths):
+        (LayoutTestFinder._real_tests):
+        (LayoutTestFinder._is_test_file):
+        (LayoutTestFinder._is_w3c_resource_file):
+        (LayoutTestFinder._strip_test_dir_prefixes):
+        (LayoutTestFinder._strip_test_dir_prefix):
+        (LayoutTestFinder._read_test_names_from_file):
+        (LayoutTestFinder._strip_comments):
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py: Renamed from Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py.
+        (MockLayoutTestFinder):
+        (MockLayoutTestFinder._real_tests):
+        (LayoutTestFinderTests):
+        (LayoutTestFinderTests.make_finder):
+        (LayoutTestFinderTests.test_supported_test_extensions):
+        (LayoutTestFinderTests.test_is_reference_html_file):
+        (LayoutTestFinderTests.test_find_no_paths_specified):
+        (LayoutTestFinderTests.test_find_one_test):
+        (LayoutTestFinderTests.test_find_glob):
+        (LayoutTestFinderTests.test_find_with_skipped_directories):
+        (LayoutTestFinderTests.test_find_with_skipped_directories_2):
+        (LayoutTestFinderTests.test_is_test_file):
+        (LayoutTestFinderTests.test_is_w3c_resource_file):
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        * Scripts/webkitpy/tool/commands/queries.py:
+
 2021-10-21  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK build with old version of ATSPI after r284367.

Modified: trunk/Tools/Scripts/open-layout-test (284594 => 284595)


--- trunk/Tools/Scripts/open-layout-test	2021-10-21 08:46:22 UTC (rev 284594)
+++ trunk/Tools/Scripts/open-layout-test	2021-10-21 09:48:26 UTC (rev 284595)
@@ -32,7 +32,7 @@
 import sys
 
 from webkitpy.common.host import Host
-from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
+from webkitpy.layout_tests.controllers.layout_test_finder_legacy import LayoutTestFinder
 from webkitpy.layout_tests.servers.run_webkit_httpd import run_server as run_webkit_httpd
 from webkitpy.layout_tests.servers.run_webkit_httpd import parse_args as parse_httpd_args
 

Deleted: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py (284594 => 284595)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py	2021-10-21 08:46:22 UTC (rev 284594)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py	2021-10-21 09:48:26 UTC (rev 284595)
@@ -1,218 +0,0 @@
-# Copyright (C) 2012 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import errno
-import json
-import logging
-import re
-
-from webkitpy.common import find_files
-from webkitpy.layout_tests.models.test import Test
-from webkitpy.port.base import Port
-
-
-_log = logging.getLogger(__name__)
-
-
-# When collecting test cases, we include any file with these extensions.
-_supported_test_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', '.py', '.htm', '.php', '.svg', '.mht', '.xht'])
-
-_skipped_filename_patterns = set([
-    # Special case for WebSocket tooling.
-    r'.*_wsh.py',
-
-    # The WebKit1 bot sometimes creates these files during the course of testing.
-    # https://webkit.org/b/208477
-    r'boot\.xml',
-    r'root\.xml'
-])
-
-
-# If any changes are made here be sure to update the isUsedInReftest method in old-run-webkit-tests as well.
-def _is_reference_html_file(filesystem, dirname, filename):
-    if filename.startswith('ref-') or filename.startswith('notref-'):
-        return True
-    filename_wihout_ext, ext = filesystem.splitext(filename)
-    # FIXME: _supported_reference_extensions should be here, https://bugs.webkit.org/show_bug.cgi?id=220421
-    if ext not in Port._supported_reference_extensions:
-        return False
-    for suffix in ['-expected', '-expected-mismatch', '-ref', '-notref']:
-        if filename_wihout_ext.endswith(suffix):
-            return True
-    return False
-
-
-def _has_supported_extension(filesystem, filename):
-    """Return true if filename is one of the file extensions we want to run a test on."""
-    extension = filesystem.splitext(filename)[1]
-    return extension in _supported_test_extensions
-
-
-class LayoutTestFinder(object):
-    """Finds LayoutTests
-
-    We consider any file will a given set of extensions as tests, except for
-    those which appear to be references (-expected.html, etc.). Notably this
-    means that a test _doesn't_ need to have any associated -expected.* file
-    (in those cases, we will report the missing result).
-    """
-
-    def __init__(self, port, options):
-        # FIXME: we should minimize/eliminate usage of the port, https://bugs.webkit.org/show_bug.cgi?id=220421
-        self._port = port
-        self._options = options
-        self._filesystem = self._port.host.filesystem
-        self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests'
-        self._w3c_resource_files = None
-        self.http_subdir = 'http' + port.TEST_PATH_SEPARATOR + 'test'
-        self.websocket_subdir = 'websocket' + port.TEST_PATH_SEPARATOR
-        self.web_platform_test_subdir = port.web_platform_test_server_doc_root()
-        self.webkit_specific_web_platform_test_subdir = (
-            'http' + port.TEST_PATH_SEPARATOR + 'wpt' + port.TEST_PATH_SEPARATOR
-        )
-
-    def find_tests(self, options, args, device_type=None):
-        paths = self._strip_test_dir_prefixes(args)
-        if options and options.test_list:
-            paths += self._strip_test_dir_prefixes(self._read_test_names_from_file(options.test_list, self._port.TEST_PATH_SEPARATOR))
-        tests = self.find_tests_by_path(paths, device_type=device_type)
-        return (paths, tests)
-
-    def find_tests_by_path(self, paths, device_type=None):
-        """Return the list of tests found. Both generic and platform-specific tests matching paths should be returned."""
-        expanded_paths = self._expanded_paths(paths, device_type=device_type)
-        return [
-            Test(
-                test_file,
-                is_http_test=self.http_subdir in test_file,
-                is_websocket_test=self.websocket_subdir in test_file,
-                is_wpt_test=(
-                    self.web_platform_test_subdir in test_file
-                    or self.webkit_specific_web_platform_test_subdir in test_file
-                ),
-            )
-            for test_file in self._real_tests(expanded_paths)
-        ]
-
-    def _expanded_paths(self, paths, device_type=None):
-        expanded_paths = []
-        fs = self._port._filesystem
-        all_platform_dirs = [path for path in fs.glob(fs.join(self._port.layout_tests_dir(), 'platform', '*')) if fs.isdir(path)]
-        for path in paths:
-            expanded_paths.append(path)
-            if self._port.test_isdir(path) and not path.startswith('platform') and not fs.isabs(path):
-                for platform_dir in all_platform_dirs:
-                    if fs.isdir(fs.join(platform_dir, path)) and platform_dir in self._port.baseline_search_path(device_type=device_type):
-                        expanded_paths.append(self._port.relative_test_filename(fs.join(platform_dir, path)))
-
-        return expanded_paths
-
-    def _real_tests(self, paths):
-        # When collecting test cases, skip these directories
-        skipped_directories = set(['.svn', '_svn', 'resources', 'support', 'script-tests', 'tools', 'reference', 'reftest'])
-        files = find_files.find(self._port._filesystem, self._port.layout_tests_dir(), paths, skipped_directories, self._is_test_file, self._port.test_key)
-        return [self._port.relative_test_filename(f) for f in files]
-
-    def _is_test_file(self, filesystem, dirname, filename):
-        if not _has_supported_extension(filesystem, filename):
-            return False
-        if _is_reference_html_file(filesystem, dirname, filename):
-            return False
-        if self._is_w3c_resource_file(filesystem, dirname, filename):
-            return False
-
-        for pattern in _skipped_filename_patterns:
-            if re.match(pattern, filename):
-                return False
-        return True
-
-    def _is_w3c_resource_file(self, filesystem, dirname, filename):
-        path = filesystem.join(dirname, filename)
-        w3c_path = filesystem.join(self._port.layout_tests_dir(), "imported", "w3c")
-        if w3c_path not in path:
-            return False
-
-        if not self._w3c_resource_files:
-            filepath = filesystem.join(w3c_path, "resources", "resource-files.json")
-            json_data = filesystem.read_text_file(filepath)
-            self._w3c_resource_files = json.loads(json_data)
-
-        _, extension = filesystem.splitext(filename)
-        if extension == '.py':
-            return True
-
-        subpath = path[len(w3c_path) + 1:].replace('\\', '/')
-        if subpath in self._w3c_resource_files["files"]:
-            return True
-        for dirpath in self._w3c_resource_files["directories"]:
-            if dirpath in subpath:
-                return True
-        return False
-
-    def _strip_test_dir_prefixes(self, paths):
-        return [self._strip_test_dir_prefix(path) for path in paths if path]
-
-    def _strip_test_dir_prefix(self, path):
-        # Handle both "LayoutTests/foo/bar.html" and "LayoutTests\foo\bar.html" if
-        # the filesystem uses '\\' as a directory separator.
-        if path.startswith(self.LAYOUT_TESTS_DIRECTORY + self._port.TEST_PATH_SEPARATOR):
-            return path[len(self.LAYOUT_TESTS_DIRECTORY + self._port.TEST_PATH_SEPARATOR):]
-        if path.startswith(self.LAYOUT_TESTS_DIRECTORY + self._filesystem.sep):
-            return path[len(self.LAYOUT_TESTS_DIRECTORY + self._filesystem.sep):]
-        return path
-
-    def _read_test_names_from_file(self, filenames, test_path_separator):
-        fs = self._filesystem
-        tests = []
-        for filename in filenames:
-            try:
-                if test_path_separator != fs.sep:
-                    filename = filename.replace(test_path_separator, fs.sep)
-                file_contents = fs.read_text_file(filename).split('\n')
-                for line in file_contents:
-                    line = self._strip_comments(line)
-                    if line:
-                        tests.append(line)
-            except IOError as e:
-                if e.errno == errno.ENOENT:
-                    _log.critical('')
-                    _log.critical('--test-list file "{}" not found'.format(filenames))
-                raise
-        return tests
-
-    @staticmethod
-    def _strip_comments(line):
-        commentIndex = line.find('//')
-        if commentIndex == -1:
-            commentIndex = len(line)
-
-        line = re.sub(r'\s+', ' ', line[:commentIndex].strip())
-        if line == '':
-            return None
-        else:
-            return line

Copied: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py (from rev 284592, trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py) (0 => 284595)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py	2021-10-21 09:48:26 UTC (rev 284595)
@@ -0,0 +1,218 @@
+# Copyright (C) 2012 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import errno
+import json
+import logging
+import re
+
+from webkitpy.common import find_files
+from webkitpy.layout_tests.models.test import Test
+from webkitpy.port.base import Port
+
+
+_log = logging.getLogger(__name__)
+
+
+# When collecting test cases, we include any file with these extensions.
+_supported_test_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', '.py', '.htm', '.php', '.svg', '.mht', '.xht'])
+
+_skipped_filename_patterns = set([
+    # Special case for WebSocket tooling.
+    r'.*_wsh.py',
+
+    # The WebKit1 bot sometimes creates these files during the course of testing.
+    # https://webkit.org/b/208477
+    r'boot\.xml',
+    r'root\.xml'
+])
+
+
+# If any changes are made here be sure to update the isUsedInReftest method in old-run-webkit-tests as well.
+def _is_reference_html_file(filesystem, dirname, filename):
+    if filename.startswith('ref-') or filename.startswith('notref-'):
+        return True
+    filename_wihout_ext, ext = filesystem.splitext(filename)
+    # FIXME: _supported_reference_extensions should be here, https://bugs.webkit.org/show_bug.cgi?id=220421
+    if ext not in Port._supported_reference_extensions:
+        return False
+    for suffix in ['-expected', '-expected-mismatch', '-ref', '-notref']:
+        if filename_wihout_ext.endswith(suffix):
+            return True
+    return False
+
+
+def _has_supported_extension(filesystem, filename):
+    """Return true if filename is one of the file extensions we want to run a test on."""
+    extension = filesystem.splitext(filename)[1]
+    return extension in _supported_test_extensions
+
+
+class LayoutTestFinder(object):
+    """Finds LayoutTests
+
+    We consider any file will a given set of extensions as tests, except for
+    those which appear to be references (-expected.html, etc.). Notably this
+    means that a test _doesn't_ need to have any associated -expected.* file
+    (in those cases, we will report the missing result).
+    """
+
+    def __init__(self, port, options):
+        # FIXME: we should minimize/eliminate usage of the port, https://bugs.webkit.org/show_bug.cgi?id=220421
+        self._port = port
+        self._options = options
+        self._filesystem = self._port.host.filesystem
+        self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests'
+        self._w3c_resource_files = None
+        self.http_subdir = 'http' + port.TEST_PATH_SEPARATOR + 'test'
+        self.websocket_subdir = 'websocket' + port.TEST_PATH_SEPARATOR
+        self.web_platform_test_subdir = port.web_platform_test_server_doc_root()
+        self.webkit_specific_web_platform_test_subdir = (
+            'http' + port.TEST_PATH_SEPARATOR + 'wpt' + port.TEST_PATH_SEPARATOR
+        )
+
+    def find_tests(self, options, args, device_type=None):
+        paths = self._strip_test_dir_prefixes(args)
+        if options and options.test_list:
+            paths += self._strip_test_dir_prefixes(self._read_test_names_from_file(options.test_list, self._port.TEST_PATH_SEPARATOR))
+        tests = self.find_tests_by_path(paths, device_type=device_type)
+        return (paths, tests)
+
+    def find_tests_by_path(self, paths, device_type=None):
+        """Return the list of tests found. Both generic and platform-specific tests matching paths should be returned."""
+        expanded_paths = self._expanded_paths(paths, device_type=device_type)
+        return [
+            Test(
+                test_file,
+                is_http_test=self.http_subdir in test_file,
+                is_websocket_test=self.websocket_subdir in test_file,
+                is_wpt_test=(
+                    self.web_platform_test_subdir in test_file
+                    or self.webkit_specific_web_platform_test_subdir in test_file
+                ),
+            )
+            for test_file in self._real_tests(expanded_paths)
+        ]
+
+    def _expanded_paths(self, paths, device_type=None):
+        expanded_paths = []
+        fs = self._port._filesystem
+        all_platform_dirs = [path for path in fs.glob(fs.join(self._port.layout_tests_dir(), 'platform', '*')) if fs.isdir(path)]
+        for path in paths:
+            expanded_paths.append(path)
+            if self._port.test_isdir(path) and not path.startswith('platform') and not fs.isabs(path):
+                for platform_dir in all_platform_dirs:
+                    if fs.isdir(fs.join(platform_dir, path)) and platform_dir in self._port.baseline_search_path(device_type=device_type):
+                        expanded_paths.append(self._port.relative_test_filename(fs.join(platform_dir, path)))
+
+        return expanded_paths
+
+    def _real_tests(self, paths):
+        # When collecting test cases, skip these directories
+        skipped_directories = set(['.svn', '_svn', 'resources', 'support', 'script-tests', 'tools', 'reference', 'reftest'])
+        files = find_files.find(self._port._filesystem, self._port.layout_tests_dir(), paths, skipped_directories, self._is_test_file, self._port.test_key)
+        return [self._port.relative_test_filename(f) for f in files]
+
+    def _is_test_file(self, filesystem, dirname, filename):
+        if not _has_supported_extension(filesystem, filename):
+            return False
+        if _is_reference_html_file(filesystem, dirname, filename):
+            return False
+        if self._is_w3c_resource_file(filesystem, dirname, filename):
+            return False
+
+        for pattern in _skipped_filename_patterns:
+            if re.match(pattern, filename):
+                return False
+        return True
+
+    def _is_w3c_resource_file(self, filesystem, dirname, filename):
+        path = filesystem.join(dirname, filename)
+        w3c_path = filesystem.join(self._port.layout_tests_dir(), "imported", "w3c")
+        if w3c_path not in path:
+            return False
+
+        if not self._w3c_resource_files:
+            filepath = filesystem.join(w3c_path, "resources", "resource-files.json")
+            json_data = filesystem.read_text_file(filepath)
+            self._w3c_resource_files = json.loads(json_data)
+
+        _, extension = filesystem.splitext(filename)
+        if extension == '.py':
+            return True
+
+        subpath = path[len(w3c_path) + 1:].replace('\\', '/')
+        if subpath in self._w3c_resource_files["files"]:
+            return True
+        for dirpath in self._w3c_resource_files["directories"]:
+            if dirpath in subpath:
+                return True
+        return False
+
+    def _strip_test_dir_prefixes(self, paths):
+        return [self._strip_test_dir_prefix(path) for path in paths if path]
+
+    def _strip_test_dir_prefix(self, path):
+        # Handle both "LayoutTests/foo/bar.html" and "LayoutTests\foo\bar.html" if
+        # the filesystem uses '\\' as a directory separator.
+        if path.startswith(self.LAYOUT_TESTS_DIRECTORY + self._port.TEST_PATH_SEPARATOR):
+            return path[len(self.LAYOUT_TESTS_DIRECTORY + self._port.TEST_PATH_SEPARATOR):]
+        if path.startswith(self.LAYOUT_TESTS_DIRECTORY + self._filesystem.sep):
+            return path[len(self.LAYOUT_TESTS_DIRECTORY + self._filesystem.sep):]
+        return path
+
+    def _read_test_names_from_file(self, filenames, test_path_separator):
+        fs = self._filesystem
+        tests = []
+        for filename in filenames:
+            try:
+                if test_path_separator != fs.sep:
+                    filename = filename.replace(test_path_separator, fs.sep)
+                file_contents = fs.read_text_file(filename).split('\n')
+                for line in file_contents:
+                    line = self._strip_comments(line)
+                    if line:
+                        tests.append(line)
+            except IOError as e:
+                if e.errno == errno.ENOENT:
+                    _log.critical('')
+                    _log.critical('--test-list file "{}" not found'.format(filenames))
+                raise
+        return tests
+
+    @staticmethod
+    def _strip_comments(line):
+        commentIndex = line.find('//')
+        if commentIndex == -1:
+            commentIndex = len(line)
+
+        line = re.sub(r'\s+', ' ', line[:commentIndex].strip())
+        if line == '':
+            return None
+        else:
+            return line

Copied: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py (from rev 284592, trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py) (0 => 284595)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py	2021-10-21 09:48:26 UTC (rev 284595)
@@ -0,0 +1,138 @@
+# Copyright (c) 2015, Canon Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/gcor other materials provided with the distribution.
+# 3.  Neither the name of Canon Inc. nor the names of
+#     its contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import optparse
+import unittest
+
+from collections import OrderedDict
+
+from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.layout_tests.controllers.layout_test_finder_legacy import LayoutTestFinder, Port, _is_reference_html_file, _supported_test_extensions
+from webkitpy.port.test import add_unit_tests_to_mock_filesystem, TestPort
+
+
+class MockLayoutTestFinder(LayoutTestFinder):
+    def _real_tests(self, paths):
+        return [path for path in paths if path.endswith('.html')]
+
+
+class LayoutTestFinderTests(unittest.TestCase):
+    def make_finder(self):
+        host = MockHost(create_stub_repository_files=True)
+        add_unit_tests_to_mock_filesystem(host.filesystem)
+        port = TestPort(host)
+        return LayoutTestFinder(port, None)
+
+    def test_supported_test_extensions(self):
+        self.assertEqual(_supported_test_extensions & Port._supported_reference_extensions, Port._supported_reference_extensions)
+
+    def test_is_reference_html_file(self):
+        filesystem = MockFileSystem()
+        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-expected.html'))
+        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-expected-mismatch.xml'))
+        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-ref.xhtml'))
+        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-notref.svg'))
+        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo.html'))
+        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.txt'))
+        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.shtml'))
+        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.php'))
+        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.mht'))
+
+    def test_find_no_paths_specified(self):
+        finder = self.make_finder()
+        tests = finder.find_tests_by_path([])
+        self.assertNotEqual(len(tests), 0)
+
+    def test_find_one_test(self):
+        finder = self.make_finder()
+        tests = finder.find_tests_by_path(['failures/expected/image.html'])
+        self.assertEqual(len(tests), 1)
+
+    def test_find_glob(self):
+        finder = self.make_finder()
+        tests = finder.find_tests_by_path(['failures/expected/im*'])
+        self.assertEqual(len(tests), 2)
+
+    def test_find_with_skipped_directories(self):
+        finder = self.make_finder()
+        tests = finder.find_tests_by_path(['userscripts'])
+        self.assertNotIn('userscripts/resources/iframe.html', [test.test_path for test in tests])
+
+    def test_find_with_skipped_directories_2(self):
+        finder = self.make_finder()
+        tests = finder.find_tests_by_path(['userscripts/resources'])
+        self.assertEqual(tests, [])
+
+    def test_is_test_file(self):
+        finder = self.make_finder()
+        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.html'))
+        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.shtml'))
+        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.svg'))
+        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'test-ref-test.html'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo.png'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.html'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.svg'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.xht'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.html'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.svg'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.xhtml'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-ref.html'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-notref.html'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-notref.xht'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-ref.xhtml'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'ref-foo.html'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'notref-foo.xhr'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo_wsh.py'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', '_wsh.py'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'boot.xml'))
+        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'root.xml'))
+        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo-boot.xml'))
+        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo-root.xml'))
+
+    def test_is_w3c_resource_file(self):
+        finder = self.make_finder()
+
+        finder._filesystem.write_text_file(finder._port.layout_tests_dir() + "/imported/w3c/resources/resource-files.json", """
+{"directories": [
+"web-platform-tests/common",
+"web-platform-tests/dom/nodes/Document-createElement-namespace-tests",
+"web-platform-tests/fonts",
+"web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/source/support",
+"web-platform-tests/html/browsers/browsing-the-web/unloading-documents/support",
+"web-platform-tests/html/browsers/history/the-history-interface/non-automated",
+"web-platform-tests/html/browsers/history/the-location-interface/non-automated",
+"web-platform-tests/images",
+"web-platform-tests/service-workers",
+"web-platform-tests/tools"
+], "files": [
+"web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-defer-scripts-subframe.html",
+"web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-not-hang-scriptloader-subframe.html"
+]}""")
+        self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3", "resource_file.html"))
+        self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c", "resource_file.html"))
+        self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c/web-platform-tests/XMLHttpRequest", "xmlhttprequest-sync-block-defer-scripts-subframe.html.html"))
+        self.assertTrue(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c/web-platform-tests/XMLHttpRequest", "xmlhttprequest-sync-block-defer-scripts-subframe.html"))
+        self.assertTrue(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-namespace-tests", "test.html"))

Deleted: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py (284594 => 284595)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py	2021-10-21 08:46:22 UTC (rev 284594)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py	2021-10-21 09:48:26 UTC (rev 284595)
@@ -1,138 +0,0 @@
-# Copyright (c) 2015, Canon Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 2.  Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/gcor other materials provided with the distribution.
-# 3.  Neither the name of Canon Inc. nor the names of
-#     its contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import optparse
-import unittest
-
-from collections import OrderedDict
-
-from webkitpy.common.host_mock import MockHost
-from webkitpy.common.system.filesystem_mock import MockFileSystem
-from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder, Port, _is_reference_html_file, _supported_test_extensions
-from webkitpy.port.test import add_unit_tests_to_mock_filesystem, TestPort
-
-
-class MockLayoutTestFinder(LayoutTestFinder):
-    def _real_tests(self, paths):
-        return [path for path in paths if path.endswith('.html')]
-
-
-class LayoutTestFinderTests(unittest.TestCase):
-    def make_finder(self):
-        host = MockHost(create_stub_repository_files=True)
-        add_unit_tests_to_mock_filesystem(host.filesystem)
-        port = TestPort(host)
-        return LayoutTestFinder(port, None)
-
-    def test_supported_test_extensions(self):
-        self.assertEqual(_supported_test_extensions & Port._supported_reference_extensions, Port._supported_reference_extensions)
-
-    def test_is_reference_html_file(self):
-        filesystem = MockFileSystem()
-        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-expected.html'))
-        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-expected-mismatch.xml'))
-        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-ref.xhtml'))
-        self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-notref.svg'))
-        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo.html'))
-        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.txt'))
-        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.shtml'))
-        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.php'))
-        self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.mht'))
-
-    def test_find_no_paths_specified(self):
-        finder = self.make_finder()
-        tests = finder.find_tests_by_path([])
-        self.assertNotEqual(len(tests), 0)
-
-    def test_find_one_test(self):
-        finder = self.make_finder()
-        tests = finder.find_tests_by_path(['failures/expected/image.html'])
-        self.assertEqual(len(tests), 1)
-
-    def test_find_glob(self):
-        finder = self.make_finder()
-        tests = finder.find_tests_by_path(['failures/expected/im*'])
-        self.assertEqual(len(tests), 2)
-
-    def test_find_with_skipped_directories(self):
-        finder = self.make_finder()
-        tests = finder.find_tests_by_path(['userscripts'])
-        self.assertNotIn('userscripts/resources/iframe.html', [test.test_path for test in tests])
-
-    def test_find_with_skipped_directories_2(self):
-        finder = self.make_finder()
-        tests = finder.find_tests_by_path(['userscripts/resources'])
-        self.assertEqual(tests, [])
-
-    def test_is_test_file(self):
-        finder = self.make_finder()
-        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.html'))
-        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.shtml'))
-        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.svg'))
-        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'test-ref-test.html'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo.png'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.html'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.svg'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.xht'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.html'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.svg'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.xhtml'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-ref.html'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-notref.html'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-notref.xht'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-ref.xhtml'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'ref-foo.html'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'notref-foo.xhr'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo_wsh.py'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', '_wsh.py'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'boot.xml'))
-        self.assertFalse(finder._is_test_file(finder._filesystem, '', 'root.xml'))
-        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo-boot.xml'))
-        self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo-root.xml'))
-
-    def test_is_w3c_resource_file(self):
-        finder = self.make_finder()
-
-        finder._filesystem.write_text_file(finder._port.layout_tests_dir() + "/imported/w3c/resources/resource-files.json", """
-{"directories": [
-"web-platform-tests/common",
-"web-platform-tests/dom/nodes/Document-createElement-namespace-tests",
-"web-platform-tests/fonts",
-"web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/source/support",
-"web-platform-tests/html/browsers/browsing-the-web/unloading-documents/support",
-"web-platform-tests/html/browsers/history/the-history-interface/non-automated",
-"web-platform-tests/html/browsers/history/the-location-interface/non-automated",
-"web-platform-tests/images",
-"web-platform-tests/service-workers",
-"web-platform-tests/tools"
-], "files": [
-"web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-defer-scripts-subframe.html",
-"web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-not-hang-scriptloader-subframe.html"
-]}""")
-        self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3", "resource_file.html"))
-        self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c", "resource_file.html"))
-        self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c/web-platform-tests/XMLHttpRequest", "xmlhttprequest-sync-block-defer-scripts-subframe.html.html"))
-        self.assertTrue(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c/web-platform-tests/XMLHttpRequest", "xmlhttprequest-sync-block-defer-scripts-subframe.html"))
-        self.assertTrue(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-namespace-tests", "test.html"))

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (284594 => 284595)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2021-10-21 08:46:22 UTC (rev 284594)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2021-10-21 09:48:26 UTC (rev 284595)
@@ -50,7 +50,7 @@
 from webkitcorepy.string_utils import pluralize
 
 from webkitpy.common.iteration_compatibility import iteritems, itervalues
-from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
+from webkitpy.layout_tests.controllers.layout_test_finder_legacy import LayoutTestFinder
 from webkitpy.layout_tests.controllers.layout_test_runner import LayoutTestRunner
 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWriter
 from webkitpy.layout_tests.layout_package import json_layout_results_generator

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queries.py (284594 => 284595)


--- trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2021-10-21 08:46:22 UTC (rev 284594)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2021-10-21 09:48:26 UTC (rev 284595)
@@ -49,7 +49,7 @@
 from webkitpy.common.net.regressionwindow import RegressionWindow
 from webkitpy.common.system.crashlogs import CrashLogs
 from webkitpy.common.system.user import User
-from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
+from webkitpy.layout_tests.controllers.layout_test_finder_legacy import LayoutTestFinder
 from webkitpy.layout_tests.models.test_expectations import TestExpectations
 from webkitpy.port import platform_options, configuration_options
 from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to