Title: [271244] trunk/Tools
Revision
271244
Author
[email protected]
Date
2021-01-07 11:34:47 -0800 (Thu, 07 Jan 2021)

Log Message

LayoutTestFinder should be in charge of finding layout tests
https://bugs.webkit.org/show_bug.cgi?id=220025

Patch by Sam Sneddon <[email protected]> on 2021-01-07
Reviewed by Jonathan Bedard.

* Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py:
(_is_reference_html_file): Formerly Port.is_reference_html_file
(_has_supported_extension): Formerly Port._has_supported_extension
(LayoutTestFinder.__init__): Define self._w3c_resource_files
(LayoutTestFinder.find_tests): Change to call within the class
(LayoutTestFinder.find_tests_by_path): Formerly Port.tests
(LayoutTestFinder._expanded_paths): Formerly Port._expanded_paths
(LayoutTestFinder._real_tests): Formerly Port._real_tests
(LayoutTestFinder._is_test_file): Formerly Port._is_test_file
(LayoutTestFinder._is_w3c_resource_file): Formerly Port._is_w3c_resource_file
(LayoutTestFinder.find_touched_tests): Update for the above
* Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py:
(MockLayoutTestFinder):
(MockLayoutTestFinder._real_tests): Move this from the former MockPort.tests
(LayoutTestFinderTests.make_finder): Similar to the make_port in base_unittest.py
(LayoutTestFinderTests.touched_files): Adjust for MockLayoutTestFinder
(LayoutTestFinderTests):
(LayoutTestFinderTests.test_is_reference_html_file): Add test to check references are subset of tests
(LayoutTestFinderTests.test_find_no_paths_specified): Formerly PortTest.test_find_no_paths_specified
(LayoutTestFinderTests.test_find_one_test): Formerly PortTest.test_find_one_test
(LayoutTestFinderTests.test_find_glob): Formerly PortTest.test_find_glob
(LayoutTestFinderTests.test_find_with_skipped_directories): Formerly PortTest.test_find_with_skipped_directories
(LayoutTestFinderTests.test_find_with_skipped_directories_2): Formerly PortTest.test_find_with_skipped_directories_2
(LayoutTestFinderTests.test_is_test_file): Formerly PortTest.test_is_test_file
(LayoutTestFinderTests.test_is_w3c_resource_file): Formerly PortTest.test_is_w3c_resource_file
(test_touched_but_skipped_test): Adjust for MockLayoutTestFinder
(MockPort): Deleted.
(LayoutTestFinderTests.test_touched_test): Deleted.
(LayoutTestFinderTests.test_expected_touched_test): Deleted.
(LayoutTestFinderTests.test_platform_expected_touched_test): Deleted.
(LayoutTestFinderTests.test_platform_duplicate_touched_test): Deleted.
(LayoutTestFinderTests.test_touched_but_skipped_test): Deleted.
* Scripts/webkitpy/layout_tests/models/test_input.py:
(TestInput.__init__): Remove unused reference_files and should_run_pixel_tests
(TestInput.__repr__): Remove unused should_run_pixel_tests
* Scripts/webkitpy/port/base.py:
(Port.tests): Deleted.
(Port._expanded_paths): Deleted.
(Port._real_tests): Deleted.
(Port.is_w3c_resource_file): Deleted.
(Port.is_reference_html_file): Deleted.
(Port._has_supported_extension): Deleted.
(Port._is_test_file): Deleted.
* Scripts/webkitpy/port/base_unittest.py:
(PortTest.test_find_no_paths_specified): Deleted.
(PortTest.test_find_one_test): Deleted.
(PortTest.test_find_glob): Deleted.
(PortTest.test_find_with_skipped_directories): Deleted.
(PortTest.test_find_with_skipped_directories_2): Deleted.
(PortTest.test_is_test_file): Deleted.
(PortTest.test_is_reference_html_file): Deleted.
(PortTest.test_tests): Deleted.
(PortTest.test_is_w3c_resource_file): Deleted.
(test_jhbuild_wrapper): Deleted.
(test_ref_tests_platform_directory): Deleted.
(test_commits_for_upload): Deleted.
* Scripts/webkitpy/port/factory.py:
(PortFactory): Remove mock_drt
* Scripts/webkitpy/port/mock_drt.py: Removed.
* Scripts/webkitpy/port/mock_drt_unittest.py: Removed.
* Scripts/webkitpy/tool/commands/queries.py:
(PrintExpectations.execute): Adjust for Port.tests moving to LayoutTestFinder
(PrintBaselines.execute): Adjust for Port._real_tests moving to LayoutTestFinder

Modified Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (271243 => 271244)


--- trunk/Tools/ChangeLog	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/ChangeLog	2021-01-07 19:34:47 UTC (rev 271244)
@@ -1,3 +1,74 @@
+2021-01-07  Sam Sneddon  <[email protected]>
+
+        LayoutTestFinder should be in charge of finding layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=220025
+
+        Reviewed by Jonathan Bedard.
+
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py:
+        (_is_reference_html_file): Formerly Port.is_reference_html_file
+        (_has_supported_extension): Formerly Port._has_supported_extension
+        (LayoutTestFinder.__init__): Define self._w3c_resource_files
+        (LayoutTestFinder.find_tests): Change to call within the class
+        (LayoutTestFinder.find_tests_by_path): Formerly Port.tests
+        (LayoutTestFinder._expanded_paths): Formerly Port._expanded_paths
+        (LayoutTestFinder._real_tests): Formerly Port._real_tests
+        (LayoutTestFinder._is_test_file): Formerly Port._is_test_file
+        (LayoutTestFinder._is_w3c_resource_file): Formerly Port._is_w3c_resource_file
+        (LayoutTestFinder.find_touched_tests): Update for the above
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py:
+        (MockLayoutTestFinder):
+        (MockLayoutTestFinder._real_tests): Move this from the former MockPort.tests
+        (LayoutTestFinderTests.make_finder): Similar to the make_port in base_unittest.py
+        (LayoutTestFinderTests.touched_files): Adjust for MockLayoutTestFinder
+        (LayoutTestFinderTests):
+        (LayoutTestFinderTests.test_is_reference_html_file): Add test to check references are subset of tests
+        (LayoutTestFinderTests.test_find_no_paths_specified): Formerly PortTest.test_find_no_paths_specified
+        (LayoutTestFinderTests.test_find_one_test): Formerly PortTest.test_find_one_test
+        (LayoutTestFinderTests.test_find_glob): Formerly PortTest.test_find_glob
+        (LayoutTestFinderTests.test_find_with_skipped_directories): Formerly PortTest.test_find_with_skipped_directories
+        (LayoutTestFinderTests.test_find_with_skipped_directories_2): Formerly PortTest.test_find_with_skipped_directories_2
+        (LayoutTestFinderTests.test_is_test_file): Formerly PortTest.test_is_test_file
+        (LayoutTestFinderTests.test_is_w3c_resource_file): Formerly PortTest.test_is_w3c_resource_file
+        (test_touched_but_skipped_test): Adjust for MockLayoutTestFinder
+        (MockPort): Deleted.
+        (LayoutTestFinderTests.test_touched_test): Deleted.
+        (LayoutTestFinderTests.test_expected_touched_test): Deleted.
+        (LayoutTestFinderTests.test_platform_expected_touched_test): Deleted.
+        (LayoutTestFinderTests.test_platform_duplicate_touched_test): Deleted.
+        (LayoutTestFinderTests.test_touched_but_skipped_test): Deleted.
+        * Scripts/webkitpy/layout_tests/models/test_input.py:
+        (TestInput.__init__): Remove unused reference_files and should_run_pixel_tests
+        (TestInput.__repr__): Remove unused should_run_pixel_tests
+        * Scripts/webkitpy/port/base.py:
+        (Port.tests): Deleted.
+        (Port._expanded_paths): Deleted.
+        (Port._real_tests): Deleted.
+        (Port.is_w3c_resource_file): Deleted.
+        (Port.is_reference_html_file): Deleted.
+        (Port._has_supported_extension): Deleted.
+        (Port._is_test_file): Deleted.
+        * Scripts/webkitpy/port/base_unittest.py:
+        (PortTest.test_find_no_paths_specified): Deleted.
+        (PortTest.test_find_one_test): Deleted.
+        (PortTest.test_find_glob): Deleted.
+        (PortTest.test_find_with_skipped_directories): Deleted.
+        (PortTest.test_find_with_skipped_directories_2): Deleted.
+        (PortTest.test_is_test_file): Deleted.
+        (PortTest.test_is_reference_html_file): Deleted.
+        (PortTest.test_tests): Deleted.
+        (PortTest.test_is_w3c_resource_file): Deleted.
+        (test_jhbuild_wrapper): Deleted.
+        (test_ref_tests_platform_directory): Deleted.
+        (test_commits_for_upload): Deleted.
+        * Scripts/webkitpy/port/factory.py:
+        (PortFactory): Remove mock_drt
+        * Scripts/webkitpy/port/mock_drt.py: Removed.
+        * Scripts/webkitpy/port/mock_drt_unittest.py: Removed.
+        * Scripts/webkitpy/tool/commands/queries.py:
+        (PrintExpectations.execute): Adjust for Port.tests moving to LayoutTestFinder
+        (PrintBaselines.execute): Adjust for Port._real_tests moving to LayoutTestFinder
+
 2021-01-07  Sihui Liu  <[email protected]>
 
         ASSERTION FAILED: !m_messageReceiverMapCount under WebKit::SpeechRecognitionServer::~SpeechRecognitionServer()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -27,29 +27,118 @@
 # 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 import test_expectations
+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', '.htm', '.php', '.svg', '.mht', '.xht'])
+
+
+# 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
 
     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))
-        test_files = self._port.tests(paths, device_type=device_type)
+        test_files = self.find_tests_by_path(paths, device_type=device_type)
         return (paths, test_files)
 
+    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 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', '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
+        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)
+
+        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 find_touched_tests(self, new_or_modified_paths, apply_skip_expectations=True):
         potential_test_paths = []
         for test_file in new_or_modified_paths:
@@ -66,7 +155,7 @@
         if not potential_test_paths:
             return None
 
-        tests = self._port.tests(list(set(potential_test_paths)))
+        tests = self.find_tests_by_path(list(set(potential_test_paths)))
         if not apply_skip_expectations:
             return tests
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -30,19 +30,22 @@
 
 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
-from webkitpy.port.test import TestPort
+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 MockPort(TestPort):
-    def __init__(self, host):
-        super(MockPort, self).__init__(host)
-
-    def tests(self, paths):
+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 touched_files(self, touched_files, fs=None):
         host = MockHost()
         if fs:
@@ -49,9 +52,94 @@
             host.filesystem = fs
         else:
             fs = host.filesystem
-        port = MockPort(host)
-        return (fs, LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files))
+        port = TestPort(host)
+        return (fs, MockLayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files))
 
+    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', 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'))
+
+    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"))
+
     def test_touched_test(self):
         paths = ['LayoutTests/test.html', 'LayoutTests/test', 'test2.html', 'Source/test1.html']
         fs, touched_tests = self.touched_files(paths)
@@ -80,7 +168,7 @@
 
     def test_touched_but_skipped_test(self):
         host = MockHost()
-        port = MockPort(host)
+        port = TestPort(host)
 
         expectations_dict = OrderedDict()
         expectations_dict['expectations'] = 'test1.html [ Skip ]\ntest3.html [ Skip ]\n'
@@ -91,5 +179,5 @@
         host.filesystem.write_text_file('/test.checkout/LayoutTests/test2.html', 'This is a test to be runned')
         host.filesystem.write_text_file('/test.checkout/LayoutTests/test3.html', 'This is a test to be skipped')
 
-        touched_tests = LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(paths)
+        touched_tests = MockLayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(paths)
         self.assertEqual(sorted(touched_tests), sorted(['test0.html', 'test2.html']))

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -31,7 +31,7 @@
 class TestInput(object):
     """Groups information about a test for easy passing of data."""
 
-    def __init__(self, test_name, timeout=None, needs_servers=None, reference_files=None, should_run_pixel_tests=None, should_dump_jsconsolelog_in_stderr=None):
+    def __init__(self, test_name, timeout=None, needs_servers=None, should_dump_jsconsolelog_in_stderr=None):
         # TestInput objects are normally constructed by the manager and passed
         # to the workers, but these some fields are set lazily in the workers where possible
         # because they require us to look at the filesystem and we want to be able to do that in parallel.
@@ -38,9 +38,8 @@
         self.test_name = test_name
         self.timeout = timeout  # in msecs; should rename this for consistency
         self.needs_servers = needs_servers
-        self.reference_files = reference_files
-        self.should_run_pixel_tests = should_run_pixel_tests
         self.should_dump_jsconsolelog_in_stderr = should_dump_jsconsolelog_in_stderr
+        self.reference_files = None
 
     def __repr__(self):
-        return "TestInput('%s', timeout=%s, needs_servers=%s, reference_files=%s, should_run_pixel_tests=%s, should_dump_jsconsolelog_in_stderr=%s)" % (self.test_name, self.timeout, self.needs_servers, self.reference_files, self.should_run_pixel_tests, self.should_dump_jsconsolelog_in_stderr)
+        return "TestInput('%s', timeout=%s, needs_servers=%s, reference_files=%s, should_dump_jsconsolelog_in_stderr=%s)" % (self.test_name, self.timeout, self.needs_servers, self.reference_files, self.should_dump_jsconsolelog_in_stderr)

Modified: trunk/Tools/Scripts/webkitpy/port/base.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/port/base.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/port/base.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -493,6 +493,8 @@
         text = string_utils.decode(self._filesystem.read_binary_file(baseline_path), target_type=str)
         return text.replace("\r\n", "\n")
 
+    _supported_reference_extensions = set(['.html', '.xml', '.xhtml', '.htm', '.svg', '.xht'])
+
     def reference_files(self, test_name, device_type=None):
         """Return a list of expectation (== or !=) and filename pairs"""
 
@@ -525,81 +527,6 @@
 
         return [self.host.filesystem.relpath(test, self.layout_tests_dir()) for test in self._filesystem.glob(re.sub('-expected.*', '.*', self._filesystem.join(self.layout_tests_dir(), path))) if self._filesystem.isfile(test)]
 
-    def tests(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 self._real_tests(expanded_paths)
-
-    def _expanded_paths(self, paths, device_type=None):
-        expanded_paths = []
-        fs = self._filesystem
-        all_platform_dirs = [path for path in fs.glob(fs.join(self.layout_tests_dir(), 'platform', '*')) if fs.isdir(path)]
-        for path in paths:
-            expanded_paths.append(path)
-            if self.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.baseline_search_path(device_type=device_type):
-                        expanded_paths.append(self.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', 'reference', 'reftest'])
-        files = find_files.find(self._filesystem, self.layout_tests_dir(), paths, skipped_directories, partial(Port._is_test_file, self), self.test_key)
-        return [self.relative_test_filename(f) for f in files]
-
-    # When collecting test cases, we include any file with these extensions.
-    _supported_test_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', '.htm', '.php', '.svg', '.mht', '.xht'])
-    _supported_reference_extensions = set(['.html', '.xml', '.xhtml', '.htm', '.svg', '.xht'])
-
-    def is_w3c_resource_file(self, filesystem, dirname, filename):
-        path = filesystem.join(dirname, filename)
-        w3c_path = filesystem.join(self.layout_tests_dir(), "imported", "w3c")
-        if not w3c_path 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)
-
-        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
-
-    @staticmethod
-    # 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)
-        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
-
-    @staticmethod
-    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 Port._supported_test_extensions
-
-    def _is_test_file(self, filesystem, dirname, filename):
-        if not Port._has_supported_extension(filesystem, filename):
-            return False
-        if Port.is_reference_html_file(filesystem, dirname, filename):
-            return False
-        if self.is_w3c_resource_file(filesystem, dirname, filename):
-            return False
-        return True
-
     def test_key(self, test_name):
         """Turns a test name into a list with two sublists, the natural key of the
         dirname, and the natural key of the basename.

Modified: trunk/Tools/Scripts/webkitpy/port/base_unittest.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/port/base_unittest.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/port/base_unittest.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -232,63 +232,6 @@
         port._filesystem = MockFileSystem({'/mock-checkout/LayoutTests/platform/foo/TestExpectations': ''})
         self.assertTrue(port.uses_test_expectations_file())
 
-    def test_find_no_paths_specified(self):
-        port = self.make_port(with_tests=True)
-        tests = port.tests([])
-        self.assertNotEqual(len(tests), 0)
-
-    def test_find_one_test(self):
-        port = self.make_port(with_tests=True)
-        tests = port.tests(['failures/expected/image.html'])
-        self.assertEqual(len(tests), 1)
-
-    def test_find_glob(self):
-        port = self.make_port(with_tests=True)
-        tests = port.tests(['failures/expected/im*'])
-        self.assertEqual(len(tests), 2)
-
-    def test_find_with_skipped_directories(self):
-        port = self.make_port(with_tests=True)
-        tests = port.tests(['userscripts'])
-        self.assertNotIn('userscripts/resources/iframe.html', tests)
-
-    def test_find_with_skipped_directories_2(self):
-        port = self.make_port(with_tests=True)
-        tests = port.tests(['userscripts/resources'])
-        self.assertEqual(tests, [])
-
-    def test_is_test_file(self):
-        port = self.make_port()
-        self.assertTrue(port._is_test_file(port.host.filesystem, '', 'foo.html'))
-        self.assertTrue(port._is_test_file(port.host.filesystem, '', 'foo.shtml'))
-        self.assertTrue(port._is_test_file(port.host.filesystem, '', 'foo.svg'))
-        self.assertTrue(port._is_test_file(port.host.filesystem, '', 'test-ref-test.html'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo.png'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected.html'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected.svg'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected.xht'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected-mismatch.html'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected-mismatch.svg'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected-mismatch.xhtml'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-ref.html'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-notref.html'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-notref.xht'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-ref.xhtml'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'ref-foo.html'))
-        self.assertFalse(port._is_test_file(port.host.filesystem, '', 'notref-foo.xhr'))
-
-    def test_is_reference_html_file(self):
-        filesystem = MockFileSystem()
-        self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-expected.html'))
-        self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-expected-mismatch.xml'))
-        self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-ref.xhtml'))
-        self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-notref.svg'))
-        self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo.html'))
-        self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.txt'))
-        self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.shtml'))
-        self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.php'))
-        self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.mht'))
-
     def test_reference_files(self):
         port = self.make_port(with_tests=True)
         self.assertEqual(port.reference_files('passes/svgreftest.svg'), [('==', port.layout_tests_dir() + '/passes/svgreftest-expected.svg')])
@@ -339,14 +282,6 @@
         self.assertFalse(port.test_isdir('passes/does_not_exist.html'))
         self.assertFalse(port.test_isdir('passes/does_not_exist/'))
 
-    def test_tests(self):
-        port = self.make_port(with_tests=True)
-        tests = port.tests([])
-        self.assertIn('passes/text.html', tests)
-
-        tests = port.tests(['passes'])
-        self.assertIn('passes/text.html', tests)
-
     def test_build_path(self):
         port = self.make_port(
             executive=MockExecutive2(output='/default-build-path/Debug'),
@@ -360,30 +295,6 @@
         )
         self.assertEqual(port._build_path(), '/my-build-directory/Debug-embedded-port')
 
-    def test_is_w3c_resource_file(self):
-        port = self.make_port()
-        port.host.filesystem.write_text_file(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(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3", "resource_file.html"))
-        self.assertFalse(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3c", "resource_file.html"))
-        self.assertFalse(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3c/web-platform-tests/XMLHttpRequest", "xmlhttprequest-sync-block-defer-scripts-subframe.html.html"))
-        self.assertTrue(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3c/web-platform-tests/XMLHttpRequest", "xmlhttprequest-sync-block-defer-scripts-subframe.html"))
-        self.assertTrue(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-namespace-tests", "test.html"))
-
     def test_jhbuild_wrapper(self):
         port = self.make_port(port_name='foo')
         port.port_name = 'foo'

Modified: trunk/Tools/Scripts/webkitpy/port/factory.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/port/factory.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/port/factory.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -116,7 +116,6 @@
         'jsc_only.JscOnlyPort',
         'mac.MacCatalystPort',
         'mac.MacPort',
-        'mock_drt.MockDRTPort',
         'test.TestPort',
         'win.FTWPort',
         'win.WinCairoPort',

Deleted: trunk/Tools/Scripts/webkitpy/port/mock_drt.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/port/mock_drt.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/port/mock_drt.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -1,244 +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 Google name 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.
-
-"""
-This is an implementation of the Port interface that overrides other
-ports and changes the Driver binary to "MockDRT".
-
-The MockDRT objects emulate what a real DRT would do. In particular, they
-return the output a real DRT would return for a given test, assuming that
-test actually passes (except for reftests, which currently cause the
-MockDRT to crash).
-"""
-
-import base64
-import logging
-import optparse
-import os
-import sys
-
-# Since we execute this script directly as part of the unit tests, we need to ensure
-# that Tools/Scripts is in sys.path for the next imports to work correctly.
-script_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
-if script_dir not in sys.path:
-    sys.path.append(script_dir)
-
-from webkitpy.common.system.systemhost import SystemHost
-from webkitpy.port.driver import DriverInput, DriverOutput, DriverProxy
-from webkitpy.port.factory import PortFactory
-
-from webkitcorepy import string_utils
-
-_log = logging.getLogger(__name__)
-
-
-class MockDRTPort(object):
-    port_name = 'mock'
-
-    @classmethod
-    def determine_full_port_name(cls, host, options, port_name):
-        return port_name
-
-    def __init__(self, host, port_name, **kwargs):
-        self.__delegate = PortFactory(host).get(port_name.replace('mock-', ''), **kwargs)
-
-    def __getattr__(self, name):
-        return getattr(self.__delegate, name)
-
-    def check_build(self):
-        return True
-
-    def check_sys_deps(self):
-        return True
-
-    def create_driver(self, worker_number, no_timeout=False):
-        # The magic of the MockDRTPort is that we create a driver that has a
-        # cmd_line() method monkey-patched to invoke this script instead of DRT.
-        return DriverProxy(self, worker_number, self._mocked_driver_maker, pixel_tests=self.get_option('pixel_tests'), no_timeout=no_timeout)
-
-    @staticmethod
-    def _mocked_driver_maker(port, worker_number, pixel_tests, no_timeout=False):
-        path_to_this_file = port.host.filesystem.abspath(__file__.replace('.pyc', '.py'))
-        driver = port.__delegate._driver_class()(port, worker_number, pixel_tests, no_timeout)
-        driver.cmd_line = port._overriding_cmd_line(driver.cmd_line,
-                                                    port.__delegate._path_to_driver(),
-                                                    sys.executable,
-                                                    path_to_this_file,
-                                                    port.__delegate.name())
-        return driver
-
-    @staticmethod
-    def _overriding_cmd_line(original_cmd_line, driver_path, python_exe, this_file, port_name):
-        def new_cmd_line(pixel_tests, per_test_args):
-            cmd_line = original_cmd_line(pixel_tests, per_test_args)
-            index = cmd_line.index(driver_path)
-            cmd_line[index:index + 1] = [python_exe, this_file, '--platform', port_name]
-            return cmd_line
-
-        return new_cmd_line
-
-    def start_helper(self, pixel_tests=False, prefer_integrated_gpu=False):
-        pass
-
-    def start_http_server(self, number_of_servers):
-        pass
-
-    def start_websocket_server(self):
-        pass
-
-    def stop_helper(self):
-        pass
-
-    def stop_http_server(self):
-        pass
-
-    def stop_websocket_server(self):
-        pass
-
-    def show_results_html_file(self, results_filename):
-        pass
-
-
-def main(argv, host, stdin, stdout, stderr):
-    """Run the tests."""
-
-    options, args = parse_options(argv)
-    drt = MockDRT(options, args, host, stdin, stdout, stderr)
-    return drt.run()
-
-
-def parse_options(argv):
-    # FIXME: We have to do custom arg parsing instead of using the optparse
-    # module.  First, Chromium and non-Chromium DRTs have a different argument
-    # syntax.  Chromium uses --pixel-tests=<path>, and non-Chromium uses
-    # --pixel-tests as a boolean flag. Second, we don't want to have to list
-    # every command line flag DRT accepts, but optparse complains about
-    # unrecognized flags. At some point it might be good to share a common
-    # DRT options class between this file and webkit.py and chromium.py
-    # just to get better type checking.
-    platform_index = argv.index('--platform')
-    platform = argv[platform_index + 1]
-
-    pixel_tests = '--pixel-tests' in argv
-    return (optparse.Values({'platform': platform, 'pixel_tests': pixel_tests}), argv)
-
-
-class MockDRT(object):
-    def __init__(self, options, args, host, stdin, stdout, stderr):
-        self._options = options
-        self._args = args
-        self._host = host
-        self._stdout = stdout
-        self._stdin = stdin
-        self._stderr = stderr
-
-        port_name = None
-        if options.platform:
-            port_name = options.platform
-        self._port = PortFactory(host).get(port_name=port_name, options=options)
-        self._driver = self._port.create_driver(0)
-
-    def run(self):
-        while True:
-            line = self._stdin.readline()
-            if not line:
-                return 0
-            driver_input = self.input_from_line(line)
-            dirname, basename = self._port.split_test(driver_input.test_name)
-            is_reftest = (self._port.reference_files(driver_input.test_name) or
-                          self._port.is_reference_html_file(self._port._filesystem, dirname, basename))
-            output = self.output_for_test(driver_input, is_reftest)
-            self.write_test_output(driver_input, output, is_reftest)
-
-    def input_from_line(self, line):
-        vals = line.strip().split("'")
-        if len(vals) == 1:
-            uri = vals[0]
-            checksum = None
-        else:
-            uri = vals[0]
-            checksum = vals[1]
-        if uri.startswith('http://') or uri.startswith('https://'):
-            test_name = self._driver.uri_to_test(uri)
-        else:
-            test_name = self._port.relative_test_filename(uri)
-
-        return DriverInput(test_name, 0, checksum, self._options.pixel_tests)
-
-    def output_for_test(self, test_input, is_reftest):
-        port = self._port
-        actual_text = port.expected_text(test_input.test_name)
-        actual_audio = port.expected_audio(test_input.test_name)
-        actual_image = None
-        actual_checksum = None
-        if is_reftest:
-            # Make up some output for reftests.
-            actual_text = 'reference text\n'
-            actual_checksum = 'mock-checksum'
-            actual_image = 'blank'
-            if test_input.test_name.endswith('-mismatch.html'):
-                actual_text = 'not reference text\n'
-                actual_checksum = 'not-mock-checksum'
-                actual_image = 'not blank'
-        elif self._options.pixel_tests and test_input.image_hash:
-            actual_checksum = port.expected_checksum(test_input.test_name)
-            actual_image = port.expected_image(test_input.test_name)
-
-        return DriverOutput(actual_text, actual_image, actual_checksum, actual_audio)
-
-    def write_test_output(self, test_input, output, is_reftest):
-        if output.audio:
-            self._stdout.write('Content-Type: audio/wav\n')
-            self._stdout.write('Content-Transfer-Encoding: base64\n')
-            self._stdout.write(base64.b64encode(output.audio))
-        else:
-            self._stdout.write('Content-Type: text/plain\n')
-            # FIXME: Note that we don't ensure there is a trailing newline!
-            # This mirrors actual (Mac) DRT behavior but is a bug.
-            if output.text:
-                self._stdout.write(output.text)
-
-        self._stdout.write('#EOF\n')
-
-        if self._options.pixel_tests and output.image_hash:
-            self._stdout.write('\n')
-            self._stdout.write('ActualHash: %s\n' % output.image_hash)
-            self._stdout.write('ExpectedHash: %s\n' % test_input.image_hash)
-            if output.image_hash != test_input.image_hash:
-                self._stdout.write('Content-Type: image/png\n')
-                self._stdout.write('Content-Length: %s\n' % len(output.image))
-                self._stdout.write(string_utils.decode(output.image, target_type=str))
-        self._stdout.write('#EOF\n')
-        self._stdout.flush()
-        self._stderr.write('#EOF\n')
-        self._stderr.flush()
-
-if __name__ == '__main__':
-    # Note that the Mock in MockDRT refers to the fact that it is emulating a
-    # real DRT, and as such, it needs access to a real SystemHost, not a MockSystemHost.
-    sys.exit(main(sys.argv[1:], SystemHost(), sys.stdin, sys.stdout, sys.stderr))

Deleted: trunk/Tools/Scripts/webkitpy/port/mock_drt_unittest.py (271243 => 271244)


--- trunk/Tools/Scripts/webkitpy/port/mock_drt_unittest.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/port/mock_drt_unittest.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -1,208 +0,0 @@
-# Copyright (C) 2011 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.
-
-"""Unit tests for MockDRT."""
-
-import unittest
-
-from webkitcorepy import StringIO
-
-from webkitpy.common.system.systemhost_mock import MockSystemHost
-from webkitpy.port import mock_drt
-from webkitpy.port import port_testcase
-from webkitpy.port import test
-from webkitpy.port.factory import PortFactory
-from webkitpy.tool import mocktool
-
-
-mock_options = mocktool.MockOptions(configuration='Release')
-
-
-class MockDRTPortTest(port_testcase.PortTestCase):
-
-    def make_port(self, options=mock_options):
-        host = MockSystemHost()
-        test.add_unit_tests_to_mock_filesystem(host.filesystem)
-        return mock_drt.MockDRTPort(host, port_name='mock-mac-lion', options=options)
-
-    def test_port_name_in_constructor(self):
-        self.assertTrue(mock_drt.MockDRTPort(MockSystemHost(), port_name='mock-test'))
-
-    def test_check_sys_deps(self):
-        pass
-
-    def test_diff_image(self):
-        pass
-
-    def test_diff_image_crashed(self):
-        pass
-
-    def test_uses_apache(self):
-        pass
-
-    def integration_test_start_helper(self):
-        pass
-
-    def integration_test_http_server__normal(self):
-        pass
-
-    def integration_test_http_server__fails(self):
-        pass
-
-    def integration_test_websocket_server__normal(self):
-        pass
-
-    def integration_test_websocket_server__fails(self):
-        pass
-
-    def integration_test_helper(self):
-        pass
-
-    def test_get_crash_log(self):
-        pass
-
-    def test_check_build(self):
-        pass
-
-    def test_asan_upload_configuration(self):
-        pass
-
-
-class MockDRTTest(unittest.TestCase):
-    def input_line(self, port, test_name, checksum=None):
-        url = ""
-        if url.startswith('file://'):
-            url = ""
-
-        if checksum:
-            return url + "'" + checksum + '\n'
-        return url + '\n'
-
-    def extra_args(self, pixel_tests):
-        if pixel_tests:
-            return ['--pixel-tests', '-']
-        return ['-']
-
-    def make_drt(self, options, args, host, stdin, stdout, stderr):
-        return mock_drt.MockDRT(options, args, host, stdin, stdout, stderr)
-
-    def make_input_output(self, port, test_name, pixel_tests,
-                          expected_checksum, drt_output, drt_input=None, expected_text=None):
-        if pixel_tests:
-            if not expected_checksum:
-                expected_checksum = port.expected_checksum(test_name)
-        if not drt_input:
-            drt_input = self.input_line(port, test_name, expected_checksum)
-        text_output = expected_text or port.expected_text(test_name) or ''
-
-        if not drt_output:
-            drt_output = self.expected_output(port, test_name, pixel_tests,
-                                              text_output, expected_checksum)
-        return (drt_input, drt_output)
-
-    def expected_output(self, port, test_name, pixel_tests, text_output, expected_checksum):
-        output = ['Content-Type: text/plain\n']
-        if text_output:
-            output.append(text_output)
-        output.append('#EOF\n')
-        if pixel_tests and expected_checksum:
-            output.extend(['\n',
-                           'ActualHash: %s\n' % expected_checksum,
-                           'ExpectedHash: %s\n' % expected_checksum])
-        output.append('#EOF\n')
-        return output
-
-    def assertTest(self, test_name, pixel_tests, expected_checksum=None, drt_output=None, host=None, expected_text=None):
-        port_name = 'test'
-        host = host or MockSystemHost()
-        test.add_unit_tests_to_mock_filesystem(host.filesystem)
-        port = PortFactory(host).get(port_name)
-        drt_input, drt_output = self.make_input_output(port, test_name,
-            pixel_tests, expected_checksum, drt_output, drt_input=None, expected_text=expected_text)
-
-        args = ['--platform', port_name] + self.extra_args(pixel_tests)
-        stdin = StringIO(drt_input)
-        stdout = StringIO()
-        stderr = StringIO()
-        options, args = mock_drt.parse_options(args)
-
-        drt = self.make_drt(options, args, host, stdin, stdout, stderr)
-        res = drt.run()
-
-        self.assertEqual(res, 0)
-
-        self.assertEqual(stdout.getvalue(), ''.join(drt_output))
-        self.assertEqual(stderr.getvalue(), '#EOF\n')
-
-    def test_main(self):
-        host = MockSystemHost()
-        test.add_unit_tests_to_mock_filesystem(host.filesystem)
-        stdin = StringIO()
-        stdout = StringIO()
-        stderr = StringIO()
-        res = mock_drt.main(['--platform', 'test'] + self.extra_args(False),
-                            host, stdin, stdout, stderr)
-        self.assertEqual(res, 0)
-        self.assertEqual(stdout.getvalue(), '')
-        self.assertEqual(stderr.getvalue(), '')
-        self.assertEqual(host.filesystem.written_files, {})
-
-    def test_pixeltest_passes(self):
-        # This also tests that we handle HTTP: test URLs properly.
-        self.assertTest('http/tests/passes/text.html', True)
-
-    def test_pixeltest__fails(self):
-        self.assertTest('failures/expected/image_checksum.html', pixel_tests=True,
-            expected_checksum='image_checksum-checksum',
-            drt_output=['Content-Type: text/plain\n',
-                        'image_checksum-txt',
-                        '#EOF\n',
-                        '\n',
-                        'ActualHash: image_checksum-checksum\n',
-                        'ExpectedHash: image_checksum-checksum\n',
-                        '#EOF\n'])
-
-    def test_textonly(self):
-        self.assertTest('passes/image.html', False)
-
-    def test_checksum_in_png(self):
-        self.assertTest('passes/checksum_in_image.html', True)
-
-    def test_missing_image(self):
-        self.assertTest('failures/expected/missing_image.html', True)
-
-    def test_missing_text(self):
-        self.assertTest('failures/expected/missing_text.html', True)
-
-    def test_reftest_match(self):
-        self.assertTest('passes/reftest.html', False, expected_checksum='mock-checksum', expected_text='reference text\n')
-        self.assertTest('passes/reftest.html', True, expected_checksum='mock-checksum', expected_text='reference text\n')
-
-    def test_reftest_mismatch(self):
-        self.assertTest('passes/mismatch.html', False, expected_checksum='mock-checksum', expected_text='reference text\n')
-        self.assertTest('passes/mismatch.html', True, expected_checksum='mock-checksum', expected_text='reference text\n')

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


--- trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2021-01-07 18:47:58 UTC (rev 271243)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries.py	2021-01-07 19:34:47 UTC (rev 271244)
@@ -50,6 +50,7 @@
 from webkitpy.tool.commands.abstractsequencedcommand import AbstractSequencedCommand
 from webkitpy.tool.grammar import pluralize
 from webkitpy.tool.multicommandtool import Command
+from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder
 from webkitpy.layout_tests.models.test_expectations import TestExpectations
 from webkitpy.port import platform_options, configuration_options
 
@@ -489,7 +490,8 @@
                 print(file)
             return
 
-        tests = set(default_port.tests(args))
+        finder = LayoutTestFinder(default_port, None)
+        tests = set(finder.find_tests_by_path(args))
         for port_name in port_names:
             model = self._model(options, port_name, tests)
             tests_to_print = self._filter_tests(options, model, tests)
@@ -553,7 +555,8 @@
             port_names = [default_port.name()]
 
         # FIXME: make real_tests() a public method.
-        tests = sorted(default_port._real_tests(args))
+        finder = LayoutTestFinder(default_port, None)
+        tests = sorted(finder._real_tests(args))
 
         for port_name in port_names:
             if port_name != port_names[0]:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to