Changeset 271244 in webkit
- Timestamp:
- Jan 7, 2021, 11:34:47 AM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 deleted
- 8 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py (modified) (4 diffs)
-
Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py (modified) (4 diffs)
-
Scripts/webkitpy/layout_tests/models/test_input.py (modified) (2 diffs)
-
Scripts/webkitpy/port/base.py (modified) (2 diffs)
-
Scripts/webkitpy/port/base_unittest.py (modified) (3 diffs)
-
Scripts/webkitpy/port/factory.py (modified) (1 diff)
-
Scripts/webkitpy/port/mock_drt.py (deleted)
-
Scripts/webkitpy/port/mock_drt_unittest.py (deleted)
-
Scripts/webkitpy/tool/commands/queries.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r271238 r271244 1 2021-01-07 Sam Sneddon <gsnedders@apple.com> 2 3 LayoutTestFinder should be in charge of finding layout tests 4 https://bugs.webkit.org/show_bug.cgi?id=220025 5 6 Reviewed by Jonathan Bedard. 7 8 * Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py: 9 (_is_reference_html_file): Formerly Port.is_reference_html_file 10 (_has_supported_extension): Formerly Port._has_supported_extension 11 (LayoutTestFinder.__init__): Define self._w3c_resource_files 12 (LayoutTestFinder.find_tests): Change to call within the class 13 (LayoutTestFinder.find_tests_by_path): Formerly Port.tests 14 (LayoutTestFinder._expanded_paths): Formerly Port._expanded_paths 15 (LayoutTestFinder._real_tests): Formerly Port._real_tests 16 (LayoutTestFinder._is_test_file): Formerly Port._is_test_file 17 (LayoutTestFinder._is_w3c_resource_file): Formerly Port._is_w3c_resource_file 18 (LayoutTestFinder.find_touched_tests): Update for the above 19 * Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py: 20 (MockLayoutTestFinder): 21 (MockLayoutTestFinder._real_tests): Move this from the former MockPort.tests 22 (LayoutTestFinderTests.make_finder): Similar to the make_port in base_unittest.py 23 (LayoutTestFinderTests.touched_files): Adjust for MockLayoutTestFinder 24 (LayoutTestFinderTests): 25 (LayoutTestFinderTests.test_is_reference_html_file): Add test to check references are subset of tests 26 (LayoutTestFinderTests.test_find_no_paths_specified): Formerly PortTest.test_find_no_paths_specified 27 (LayoutTestFinderTests.test_find_one_test): Formerly PortTest.test_find_one_test 28 (LayoutTestFinderTests.test_find_glob): Formerly PortTest.test_find_glob 29 (LayoutTestFinderTests.test_find_with_skipped_directories): Formerly PortTest.test_find_with_skipped_directories 30 (LayoutTestFinderTests.test_find_with_skipped_directories_2): Formerly PortTest.test_find_with_skipped_directories_2 31 (LayoutTestFinderTests.test_is_test_file): Formerly PortTest.test_is_test_file 32 (LayoutTestFinderTests.test_is_w3c_resource_file): Formerly PortTest.test_is_w3c_resource_file 33 (test_touched_but_skipped_test): Adjust for MockLayoutTestFinder 34 (MockPort): Deleted. 35 (LayoutTestFinderTests.test_touched_test): Deleted. 36 (LayoutTestFinderTests.test_expected_touched_test): Deleted. 37 (LayoutTestFinderTests.test_platform_expected_touched_test): Deleted. 38 (LayoutTestFinderTests.test_platform_duplicate_touched_test): Deleted. 39 (LayoutTestFinderTests.test_touched_but_skipped_test): Deleted. 40 * Scripts/webkitpy/layout_tests/models/test_input.py: 41 (TestInput.__init__): Remove unused reference_files and should_run_pixel_tests 42 (TestInput.__repr__): Remove unused should_run_pixel_tests 43 * Scripts/webkitpy/port/base.py: 44 (Port.tests): Deleted. 45 (Port._expanded_paths): Deleted. 46 (Port._real_tests): Deleted. 47 (Port.is_w3c_resource_file): Deleted. 48 (Port.is_reference_html_file): Deleted. 49 (Port._has_supported_extension): Deleted. 50 (Port._is_test_file): Deleted. 51 * Scripts/webkitpy/port/base_unittest.py: 52 (PortTest.test_find_no_paths_specified): Deleted. 53 (PortTest.test_find_one_test): Deleted. 54 (PortTest.test_find_glob): Deleted. 55 (PortTest.test_find_with_skipped_directories): Deleted. 56 (PortTest.test_find_with_skipped_directories_2): Deleted. 57 (PortTest.test_is_test_file): Deleted. 58 (PortTest.test_is_reference_html_file): Deleted. 59 (PortTest.test_tests): Deleted. 60 (PortTest.test_is_w3c_resource_file): Deleted. 61 (test_jhbuild_wrapper): Deleted. 62 (test_ref_tests_platform_directory): Deleted. 63 (test_commits_for_upload): Deleted. 64 * Scripts/webkitpy/port/factory.py: 65 (PortFactory): Remove mock_drt 66 * Scripts/webkitpy/port/mock_drt.py: Removed. 67 * Scripts/webkitpy/port/mock_drt_unittest.py: Removed. 68 * Scripts/webkitpy/tool/commands/queries.py: 69 (PrintExpectations.execute): Adjust for Port.tests moving to LayoutTestFinder 70 (PrintBaselines.execute): Adjust for Port._real_tests moving to LayoutTestFinder 71 1 72 2021-01-07 Sihui Liu <sihui_liu@appe.com> 2 73 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder.py
r268925 r271244 28 28 29 29 import errno 30 import json 30 31 import logging 31 32 import re 32 33 34 from webkitpy.common import find_files 33 35 from webkitpy.layout_tests.models import test_expectations 36 from webkitpy.port.base import Port 34 37 35 38 … … 37 40 38 41 42 # When collecting test cases, we include any file with these extensions. 43 _supported_test_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', '.htm', '.php', '.svg', '.mht', '.xht']) 44 45 46 # If any changes are made here be sure to update the isUsedInReftest method in old-run-webkit-tests as well. 47 def _is_reference_html_file(filesystem, dirname, filename): 48 if filename.startswith('ref-') or filename.startswith('notref-'): 49 return True 50 filename_wihout_ext, ext = filesystem.splitext(filename) 51 # FIXME: _supported_reference_extensions should be here, https://bugs.webkit.org/show_bug.cgi?id=220421 52 if ext not in Port._supported_reference_extensions: 53 return False 54 for suffix in ['-expected', '-expected-mismatch', '-ref', '-notref']: 55 if filename_wihout_ext.endswith(suffix): 56 return True 57 return False 58 59 60 def _has_supported_extension(filesystem, filename): 61 """Return true if filename is one of the file extensions we want to run a test on.""" 62 extension = filesystem.splitext(filename)[1] 63 return extension in _supported_test_extensions 64 65 39 66 class LayoutTestFinder(object): 67 """Finds LayoutTests 68 69 We consider any file will a given set of extensions as tests, except for 70 those which appear to be references (-expected.html, etc.). Notably this 71 means that a test _doesn't_ need to have any associated -expected.* file 72 (in those cases, we will report the missing result). 73 """ 74 40 75 def __init__(self, port, options): 76 # FIXME: we should minimize/eliminate usage of the port, https://bugs.webkit.org/show_bug.cgi?id=220421 41 77 self._port = port 42 78 self._options = options 43 79 self._filesystem = self._port.host.filesystem 44 80 self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests' 81 self._w3c_resource_files = None 45 82 46 83 def find_tests(self, options, args, device_type=None): … … 48 85 if options and options.test_list: 49 86 paths += self._strip_test_dir_prefixes(self._read_test_names_from_file(options.test_list, self._port.TEST_PATH_SEPARATOR)) 50 test_files = self. _port.tests(paths, device_type=device_type)87 test_files = self.find_tests_by_path(paths, device_type=device_type) 51 88 return (paths, test_files) 89 90 def find_tests_by_path(self, paths, device_type=None): 91 """Return the list of tests found. Both generic and platform-specific tests matching paths should be returned.""" 92 expanded_paths = self._expanded_paths(paths, device_type=device_type) 93 return self._real_tests(expanded_paths) 94 95 def _expanded_paths(self, paths, device_type=None): 96 expanded_paths = [] 97 fs = self._port._filesystem 98 all_platform_dirs = [path for path in fs.glob(fs.join(self._port.layout_tests_dir(), 'platform', '*')) if fs.isdir(path)] 99 for path in paths: 100 expanded_paths.append(path) 101 if self._port.test_isdir(path) and not path.startswith('platform') and not fs.isabs(path): 102 for platform_dir in all_platform_dirs: 103 if fs.isdir(fs.join(platform_dir, path)) and platform_dir in self._port.baseline_search_path(device_type=device_type): 104 expanded_paths.append(self._port.relative_test_filename(fs.join(platform_dir, path))) 105 106 return expanded_paths 107 108 def _real_tests(self, paths): 109 # When collecting test cases, skip these directories 110 skipped_directories = set(['.svn', '_svn', 'resources', 'support', 'script-tests', 'reference', 'reftest']) 111 files = find_files.find(self._port._filesystem, self._port.layout_tests_dir(), paths, skipped_directories, self._is_test_file, self._port.test_key) 112 return [self._port.relative_test_filename(f) for f in files] 113 114 def _is_test_file(self, filesystem, dirname, filename): 115 if not _has_supported_extension(filesystem, filename): 116 return False 117 if _is_reference_html_file(filesystem, dirname, filename): 118 return False 119 if self._is_w3c_resource_file(filesystem, dirname, filename): 120 return False 121 return True 122 123 def _is_w3c_resource_file(self, filesystem, dirname, filename): 124 path = filesystem.join(dirname, filename) 125 w3c_path = filesystem.join(self._port.layout_tests_dir(), "imported", "w3c") 126 if w3c_path not in path: 127 return False 128 129 if not self._w3c_resource_files: 130 filepath = filesystem.join(w3c_path, "resources", "resource-files.json") 131 json_data = filesystem.read_text_file(filepath) 132 self._w3c_resource_files = json.loads(json_data) 133 134 subpath = path[len(w3c_path) + 1:].replace('\\', '/') 135 if subpath in self._w3c_resource_files["files"]: 136 return True 137 for dirpath in self._w3c_resource_files["directories"]: 138 if dirpath in subpath: 139 return True 140 return False 52 141 53 142 def find_touched_tests(self, new_or_modified_paths, apply_skip_expectations=True): … … 67 156 return None 68 157 69 tests = self. _port.tests(list(set(potential_test_paths)))158 tests = self.find_tests_by_path(list(set(potential_test_paths))) 70 159 if not apply_skip_expectations: 71 160 return tests -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_unittest.py
r252443 r271244 31 31 from webkitpy.common.host_mock import MockHost 32 32 from webkitpy.common.system.filesystem_mock import MockFileSystem 33 from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder 34 from webkitpy.port.test import TestPort33 from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder, Port, _is_reference_html_file, _supported_test_extensions 34 from webkitpy.port.test import add_unit_tests_to_mock_filesystem, TestPort 35 35 36 36 37 class MockPort(TestPort): 38 def __init__(self, host): 39 super(MockPort, self).__init__(host) 40 41 def tests(self, paths): 37 class MockLayoutTestFinder(LayoutTestFinder): 38 def _real_tests(self, paths): 42 39 return [path for path in paths if path.endswith('.html')] 43 40 44 41 45 42 class LayoutTestFinderTests(unittest.TestCase): 43 def make_finder(self): 44 host = MockHost(create_stub_repository_files=True) 45 add_unit_tests_to_mock_filesystem(host.filesystem) 46 port = TestPort(host) 47 return LayoutTestFinder(port, None) 48 46 49 def touched_files(self, touched_files, fs=None): 47 50 host = MockHost() … … 50 53 else: 51 54 fs = host.filesystem 52 port = MockPort(host) 53 return (fs, LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files)) 55 port = TestPort(host) 56 return (fs, MockLayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files)) 57 58 def test_supported_test_extensions(self): 59 self.assertEqual(_supported_test_extensions & Port._supported_reference_extensions, Port._supported_reference_extensions) 60 61 def test_is_reference_html_file(self): 62 filesystem = MockFileSystem() 63 self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-expected.html')) 64 self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-expected-mismatch.xml')) 65 self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-ref.xhtml')) 66 self.assertTrue(_is_reference_html_file(filesystem, '', 'foo-notref.svg')) 67 self.assertFalse(_is_reference_html_file(filesystem, '', 'foo.html')) 68 self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.txt')) 69 self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.shtml')) 70 self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.php')) 71 self.assertFalse(_is_reference_html_file(filesystem, '', 'foo-expected.mht')) 72 73 def test_find_no_paths_specified(self): 74 finder = self.make_finder() 75 tests = finder.find_tests_by_path([]) 76 self.assertNotEqual(len(tests), 0) 77 78 def test_find_one_test(self): 79 finder = self.make_finder() 80 tests = finder.find_tests_by_path(['failures/expected/image.html']) 81 self.assertEqual(len(tests), 1) 82 83 def test_find_glob(self): 84 finder = self.make_finder() 85 tests = finder.find_tests_by_path(['failures/expected/im*']) 86 self.assertEqual(len(tests), 2) 87 88 def test_find_with_skipped_directories(self): 89 finder = self.make_finder() 90 tests = finder.find_tests_by_path(['userscripts']) 91 self.assertNotIn('userscripts/resources/iframe.html', tests) 92 93 def test_find_with_skipped_directories_2(self): 94 finder = self.make_finder() 95 tests = finder.find_tests_by_path(['userscripts/resources']) 96 self.assertEqual(tests, []) 97 98 def test_is_test_file(self): 99 finder = self.make_finder() 100 self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.html')) 101 self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.shtml')) 102 self.assertTrue(finder._is_test_file(finder._filesystem, '', 'foo.svg')) 103 self.assertTrue(finder._is_test_file(finder._filesystem, '', 'test-ref-test.html')) 104 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo.png')) 105 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.html')) 106 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.svg')) 107 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected.xht')) 108 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.html')) 109 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.svg')) 110 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-expected-mismatch.xhtml')) 111 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-ref.html')) 112 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-notref.html')) 113 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-notref.xht')) 114 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'foo-ref.xhtml')) 115 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'ref-foo.html')) 116 self.assertFalse(finder._is_test_file(finder._filesystem, '', 'notref-foo.xhr')) 117 118 def test_is_w3c_resource_file(self): 119 finder = self.make_finder() 120 121 finder._filesystem.write_text_file(finder._port.layout_tests_dir() + "/imported/w3c/resources/resource-files.json", """ 122 {"directories": [ 123 "web-platform-tests/common", 124 "web-platform-tests/dom/nodes/Document-createElement-namespace-tests", 125 "web-platform-tests/fonts", 126 "web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/source/support", 127 "web-platform-tests/html/browsers/browsing-the-web/unloading-documents/support", 128 "web-platform-tests/html/browsers/history/the-history-interface/non-automated", 129 "web-platform-tests/html/browsers/history/the-location-interface/non-automated", 130 "web-platform-tests/images", 131 "web-platform-tests/service-workers", 132 "web-platform-tests/tools" 133 ], "files": [ 134 "web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-defer-scripts-subframe.html", 135 "web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-not-hang-scriptloader-subframe.html" 136 ]}""") 137 self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3", "resource_file.html")) 138 self.assertFalse(finder._is_w3c_resource_file(finder._filesystem, finder._port.layout_tests_dir() + "/imported/w3c", "resource_file.html")) 139 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")) 140 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")) 141 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")) 54 142 55 143 def test_touched_test(self): … … 81 169 def test_touched_but_skipped_test(self): 82 170 host = MockHost() 83 port = MockPort(host)171 port = TestPort(host) 84 172 85 173 expectations_dict = OrderedDict() … … 92 180 host.filesystem.write_text_file('/test.checkout/LayoutTests/test3.html', 'This is a test to be skipped') 93 181 94 touched_tests = LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(paths)182 touched_tests = MockLayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(paths) 95 183 self.assertEqual(sorted(touched_tests), sorted(['test0.html', 'test2.html'])) -
trunk/Tools/Scripts/webkitpy/layout_tests/models/test_input.py
r209798 r271244 32 32 """Groups information about a test for easy passing of data.""" 33 33 34 def __init__(self, test_name, timeout=None, needs_servers=None, reference_files=None, should_run_pixel_tests=None,should_dump_jsconsolelog_in_stderr=None):34 def __init__(self, test_name, timeout=None, needs_servers=None, should_dump_jsconsolelog_in_stderr=None): 35 35 # TestInput objects are normally constructed by the manager and passed 36 36 # to the workers, but these some fields are set lazily in the workers where possible … … 39 39 self.timeout = timeout # in msecs; should rename this for consistency 40 40 self.needs_servers = needs_servers 41 self.reference_files = reference_files42 self.should_run_pixel_tests = should_run_pixel_tests43 41 self.should_dump_jsconsolelog_in_stderr = should_dump_jsconsolelog_in_stderr 42 self.reference_files = None 44 43 45 44 def __repr__(self): 46 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)45 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) -
trunk/Tools/Scripts/webkitpy/port/base.py
r270954 r271244 494 494 return text.replace("\r\n", "\n") 495 495 496 _supported_reference_extensions = set(['.html', '.xml', '.xhtml', '.htm', '.svg', '.xht']) 497 496 498 def reference_files(self, test_name, device_type=None): 497 499 """Return a list of expectation (== or !=) and filename pairs""" … … 525 527 526 528 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)] 527 528 def tests(self, paths, device_type=None):529 """Return the list of tests found. Both generic and platform-specific tests matching paths should be returned."""530 expanded_paths = self._expanded_paths(paths, device_type=device_type)531 return self._real_tests(expanded_paths)532 533 def _expanded_paths(self, paths, device_type=None):534 expanded_paths = []535 fs = self._filesystem536 all_platform_dirs = [path for path in fs.glob(fs.join(self.layout_tests_dir(), 'platform', '*')) if fs.isdir(path)]537 for path in paths:538 expanded_paths.append(path)539 if self.test_isdir(path) and not path.startswith('platform') and not fs.isabs(path):540 for platform_dir in all_platform_dirs:541 if fs.isdir(fs.join(platform_dir, path)) and platform_dir in self.baseline_search_path(device_type=device_type):542 expanded_paths.append(self.relative_test_filename(fs.join(platform_dir, path)))543 544 return expanded_paths545 546 def _real_tests(self, paths):547 # When collecting test cases, skip these directories548 skipped_directories = set(['.svn', '_svn', 'resources', 'support', 'script-tests', 'reference', 'reftest'])549 files = find_files.find(self._filesystem, self.layout_tests_dir(), paths, skipped_directories, partial(Port._is_test_file, self), self.test_key)550 return [self.relative_test_filename(f) for f in files]551 552 # When collecting test cases, we include any file with these extensions.553 _supported_test_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', '.htm', '.php', '.svg', '.mht', '.xht'])554 _supported_reference_extensions = set(['.html', '.xml', '.xhtml', '.htm', '.svg', '.xht'])555 556 def is_w3c_resource_file(self, filesystem, dirname, filename):557 path = filesystem.join(dirname, filename)558 w3c_path = filesystem.join(self.layout_tests_dir(), "imported", "w3c")559 if not w3c_path in path:560 return False561 562 if not self._w3c_resource_files:563 filepath = filesystem.join(w3c_path, "resources", "resource-files.json")564 json_data = filesystem.read_text_file(filepath)565 self._w3c_resource_files = json.loads(json_data)566 567 subpath = path[len(w3c_path) + 1:].replace('\\', '/')568 if subpath in self._w3c_resource_files["files"]:569 return True570 for dirpath in self._w3c_resource_files["directories"]:571 if dirpath in subpath:572 return True573 return False574 575 @staticmethod576 # If any changes are made here be sure to update the isUsedInReftest method in old-run-webkit-tests as well.577 def is_reference_html_file(filesystem, dirname, filename):578 if filename.startswith('ref-') or filename.startswith('notref-'):579 return True580 filename_wihout_ext, ext = filesystem.splitext(filename)581 if ext not in Port._supported_reference_extensions:582 return False583 for suffix in ['-expected', '-expected-mismatch', '-ref', '-notref']:584 if filename_wihout_ext.endswith(suffix):585 return True586 return False587 588 @staticmethod589 def _has_supported_extension(filesystem, filename):590 """Return true if filename is one of the file extensions we want to run a test on."""591 extension = filesystem.splitext(filename)[1]592 return extension in Port._supported_test_extensions593 594 def _is_test_file(self, filesystem, dirname, filename):595 if not Port._has_supported_extension(filesystem, filename):596 return False597 if Port.is_reference_html_file(filesystem, dirname, filename):598 return False599 if self.is_w3c_resource_file(filesystem, dirname, filename):600 return False601 return True602 529 603 530 def test_key(self, test_name): -
trunk/Tools/Scripts/webkitpy/port/base_unittest.py
r270954 r271244 233 233 self.assertTrue(port.uses_test_expectations_file()) 234 234 235 def test_find_no_paths_specified(self):236 port = self.make_port(with_tests=True)237 tests = port.tests([])238 self.assertNotEqual(len(tests), 0)239 240 def test_find_one_test(self):241 port = self.make_port(with_tests=True)242 tests = port.tests(['failures/expected/image.html'])243 self.assertEqual(len(tests), 1)244 245 def test_find_glob(self):246 port = self.make_port(with_tests=True)247 tests = port.tests(['failures/expected/im*'])248 self.assertEqual(len(tests), 2)249 250 def test_find_with_skipped_directories(self):251 port = self.make_port(with_tests=True)252 tests = port.tests(['userscripts'])253 self.assertNotIn('userscripts/resources/iframe.html', tests)254 255 def test_find_with_skipped_directories_2(self):256 port = self.make_port(with_tests=True)257 tests = port.tests(['userscripts/resources'])258 self.assertEqual(tests, [])259 260 def test_is_test_file(self):261 port = self.make_port()262 self.assertTrue(port._is_test_file(port.host.filesystem, '', 'foo.html'))263 self.assertTrue(port._is_test_file(port.host.filesystem, '', 'foo.shtml'))264 self.assertTrue(port._is_test_file(port.host.filesystem, '', 'foo.svg'))265 self.assertTrue(port._is_test_file(port.host.filesystem, '', 'test-ref-test.html'))266 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo.png'))267 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected.html'))268 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected.svg'))269 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected.xht'))270 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected-mismatch.html'))271 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected-mismatch.svg'))272 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-expected-mismatch.xhtml'))273 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-ref.html'))274 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-notref.html'))275 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-notref.xht'))276 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'foo-ref.xhtml'))277 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'ref-foo.html'))278 self.assertFalse(port._is_test_file(port.host.filesystem, '', 'notref-foo.xhr'))279 280 def test_is_reference_html_file(self):281 filesystem = MockFileSystem()282 self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-expected.html'))283 self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-expected-mismatch.xml'))284 self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-ref.xhtml'))285 self.assertTrue(Port.is_reference_html_file(filesystem, '', 'foo-notref.svg'))286 self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo.html'))287 self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.txt'))288 self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.shtml'))289 self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.php'))290 self.assertFalse(Port.is_reference_html_file(filesystem, '', 'foo-expected.mht'))291 292 235 def test_reference_files(self): 293 236 port = self.make_port(with_tests=True) … … 340 283 self.assertFalse(port.test_isdir('passes/does_not_exist/')) 341 284 342 def test_tests(self):343 port = self.make_port(with_tests=True)344 tests = port.tests([])345 self.assertIn('passes/text.html', tests)346 347 tests = port.tests(['passes'])348 self.assertIn('passes/text.html', tests)349 350 285 def test_build_path(self): 351 286 port = self.make_port( … … 360 295 ) 361 296 self.assertEqual(port._build_path(), '/my-build-directory/Debug-embedded-port') 362 363 def test_is_w3c_resource_file(self):364 port = self.make_port()365 port.host.filesystem.write_text_file(port.layout_tests_dir() + "/imported/w3c/resources/resource-files.json", """366 {"directories": [367 "web-platform-tests/common",368 "web-platform-tests/dom/nodes/Document-createElement-namespace-tests",369 "web-platform-tests/fonts",370 "web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/source/support",371 "web-platform-tests/html/browsers/browsing-the-web/unloading-documents/support",372 "web-platform-tests/html/browsers/history/the-history-interface/non-automated",373 "web-platform-tests/html/browsers/history/the-location-interface/non-automated",374 "web-platform-tests/images",375 "web-platform-tests/service-workers",376 "web-platform-tests/tools"377 ], "files": [378 "web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-defer-scripts-subframe.html",379 "web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-not-hang-scriptloader-subframe.html"380 ]}""")381 self.assertFalse(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3", "resource_file.html"))382 self.assertFalse(port.is_w3c_resource_file(port.host.filesystem, port.layout_tests_dir() + "/imported/w3c", "resource_file.html"))383 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"))384 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"))385 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"))386 297 387 298 def test_jhbuild_wrapper(self): -
trunk/Tools/Scripts/webkitpy/port/factory.py
r271158 r271244 117 117 'mac.MacCatalystPort', 118 118 'mac.MacPort', 119 'mock_drt.MockDRTPort',120 119 'test.TestPort', 121 120 'win.FTWPort', -
trunk/Tools/Scripts/webkitpy/tool/commands/queries.py
r263714 r271244 51 51 from webkitpy.tool.grammar import pluralize 52 52 from webkitpy.tool.multicommandtool import Command 53 from webkitpy.layout_tests.controllers.layout_test_finder import LayoutTestFinder 53 54 from webkitpy.layout_tests.models.test_expectations import TestExpectations 54 55 from webkitpy.port import platform_options, configuration_options … … 490 491 return 491 492 492 tests = set(default_port.tests(args)) 493 finder = LayoutTestFinder(default_port, None) 494 tests = set(finder.find_tests_by_path(args)) 493 495 for port_name in port_names: 494 496 model = self._model(options, port_name, tests) … … 554 556 555 557 # FIXME: make real_tests() a public method. 556 tests = sorted(default_port._real_tests(args)) 558 finder = LayoutTestFinder(default_port, None) 559 tests = sorted(finder._real_tests(args)) 557 560 558 561 for port_name in port_names:
Note:
See TracChangeset
for help on using the changeset viewer.