Diff
Modified: trunk/Tools/ChangeLog (273853 => 273854)
--- trunk/Tools/ChangeLog 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/ChangeLog 2021-03-04 00:15:01 UTC (rev 273854)
@@ -1,3 +1,33 @@
+2021-03-03 Sam Sneddon <gsnedd...@apple.com>
+
+ Make LayoutTestFinder.find_tests/find_tests_by_path return List[Test]
+ https://bugs.webkit.org/show_bug.cgi?id=222662
+
+ Reviewed by Jonathan Bedard.
+
+ This introduces a Test class, to later be able to migrate finding
+ expectations to LayoutTestFinder.
+
+ * Scripts/open-layout-test:
+ (main):
+ * Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py:
+ (LayoutTestFinder.find_tests):
+ (LayoutTestFinder.find_tests_by_path):
+ * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py:
+ (LayoutTestFinderTests.test_find_with_skipped_directories):
+ * Scripts/webkitpy/layout_tests/controllers/manager.py:
+ (Manager.run):
+ (Manager.print_expectations):
+ * Scripts/webkitpy/layout_tests/models/test.py: Added.
+ (Test):
+ (Test.__init__):
+ (Test.__repr__):
+ (Test.__eq__):
+ * Scripts/webkitpy/layout_tests/models/test_input.py:
+ (TestInput):
+ * Scripts/webkitpy/tool/commands/queries.py:
+ (PrintExpectations.execute):
+
2021-03-03 Cameron McCormack <hey...@apple.com>
Send console.log() etc. to stdout in MiniBrowser on macOS
Modified: trunk/Tools/Scripts/open-layout-test (273853 => 273854)
--- trunk/Tools/Scripts/open-layout-test 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/Scripts/open-layout-test 2021-03-04 00:15:01 UTC (rev 273854)
@@ -54,7 +54,8 @@
driver = port.create_driver(0)
finder = LayoutTestFinder(port, {})
- paths, test_files = finder.find_tests(None, [test_name])
+ paths, tests = finder.find_tests(None, [test_name])
+ test_files = [test.test_path for test in tests]
test_name = paths[0]
needs_server = False
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py (273853 => 273854)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py 2021-03-04 00:15:01 UTC (rev 273854)
@@ -33,6 +33,7 @@
from webkitpy.common import find_files
from webkitpy.layout_tests.models import test_expectations
+from webkitpy.layout_tests.models.test import Test
from webkitpy.port.base import Port
@@ -84,13 +85,13 @@
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.find_tests_by_path(paths, device_type=device_type)
- return (paths, test_files)
+ 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 self._real_tests(expanded_paths)
+ return [Test(test_file) for test_file in self._real_tests(expanded_paths)]
def _expanded_paths(self, paths, device_type=None):
expanded_paths = []
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py (273853 => 273854)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py 2021-03-04 00:15:01 UTC (rev 273854)
@@ -79,7 +79,7 @@
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)
+ 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()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (273853 => 273854)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py 2021-03-04 00:15:01 UTC (rev 273854)
@@ -208,11 +208,13 @@
for_device_type = u'for {} '.format(device_type) if device_type else ''
self._printer.write_update(u'Collecting tests {}...'.format(for_device_type))
try:
- paths, test_names = self._collect_tests(args, device_type=device_type)
+ paths, tests = self._collect_tests(args, device_type=device_type)
except IOError:
# This is raised if --test-list doesn't exist
return test_run_results.RunDetails(exit_code=-1)
+ test_names = [test.test_path for test in tests]
+
self._printer.write_update(u'Parsing expectations {}...'.format(for_device_type))
self._expectations[device_type] = test_expectations.TestExpectations(self._port, test_names, force_expectations_pass=self._options.force, device_type=device_type)
self._expectations[device_type].parse_all_expectations()
@@ -696,11 +698,13 @@
for_device_type = 'for {} '.format(device_type) if device_type else ''
self._printer.write_update('Collecting tests {}...'.format(for_device_type))
try:
- paths, test_names = self._collect_tests(args, device_type=device_type)
+ paths, tests = self._collect_tests(args, device_type=device_type)
except IOError:
# This is raised if --test-list doesn't exist
return test_run_results.RunDetails(exit_code=-1)
+ test_names = [test.test_path for test in tests]
+
self._printer.write_update('Parsing expectations {}...'.format(for_device_type))
self._expectations[device_type] = test_expectations.TestExpectations(self._port, test_names, force_expectations_pass=self._options.force, device_type=device_type)
self._expectations[device_type].parse_all_expectations()
Added: trunk/Tools/Scripts/webkitpy/layout_tests/models/test.py (0 => 273854)
--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test.py 2021-03-04 00:15:01 UTC (rev 273854)
@@ -0,0 +1,76 @@
+# Copyright (C) 2021 Apple 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 Apple 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.
+
+
+class Test(object):
+ """Data about a test and its expectations.
+
+ Note that this is inherently platform specific, as expectations are platform specific."""
+
+ def __init__(
+ self,
+ test_path,
+ expected_text_path=None,
+ expected_image_path=None,
+ expected_checksum_path=None,
+ expected_audio_path=None,
+ reference_files=None,
+ ):
+ self.test_path = test_path
+ self.expected_text_path = expected_text_path
+ self.expected_image_path = expected_image_path
+ self.expected_checksum_path = expected_checksum_path
+ self.expected_audio_path = expected_audio_path
+ self.reference_files = reference_files
+
+ def __repr__(self):
+ return (
+ "Test(%r, "
+ "expected_text_path=%r, "
+ "expected_image_path=%r, "
+ "expected_checksum_path=%r, "
+ "expected_audio_path=%r, "
+ "reference_files=%r)"
+ ) % (
+ self.test_path,
+ self.expected_text_path,
+ self.expected_image_path,
+ self.expected_checksum_path,
+ self.expected_audio_path,
+ self.reference_files,
+ )
+
+ def __eq__(self, other):
+ return (
+ self.test_path == other.test_path
+ and self.expected_text_path == other.expected_text_path
+ and self.expected_image_path == other.expected_image_path
+ and self.expected_checksum_path == other.expected_checksum_path
+ and self.expected_audio_path == other.expected_audio_path
+ and self.reference_files == other.reference_files
+ )
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py (273853 => 273854)
--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py 2021-03-04 00:15:01 UTC (rev 273854)
@@ -29,8 +29,12 @@
class TestInput(object):
- """Groups information about a test for easy passing of data."""
+ """Information about a test needed to run it.
+ This differs from a Test object insofar as it contains metadata not specific to the test,
+ derived from TestExpectations/test execution options (e.g., timeout).
+ """
+
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
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queries.py (273853 => 273854)
--- trunk/Tools/Scripts/webkitpy/tool/commands/queries.py 2021-03-03 23:54:50 UTC (rev 273853)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries.py 2021-03-04 00:15:01 UTC (rev 273854)
@@ -504,10 +504,11 @@
return
finder = LayoutTestFinder(default_port, None)
- tests = set(finder.find_tests_by_path(args))
+ tests = finder.find_tests_by_path(args)
+ test_files = {test.test_path for test in tests}
for port_name in port_names:
- model = self._model(options, port_name, tests)
- tests_to_print = self._filter_tests(options, model, tests)
+ model = self._model(options, port_name, test_files)
+ tests_to_print = self._filter_tests(options, model, test_files)
lines = [model.get_expectation_line(test) for test in sorted(tests_to_print)]
if port_name != port_names[0]:
print()