Skip to content

Commit

Permalink
[import-w3c-tests] check all baselines when deleting dangling baselines
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264735

Reviewed by Jonathan Bedard.

Previously, we found the first baseline for the current port, and
preserved that baseline. This is, of course, wrong: we need to preserve
baselines for all platforms, including (and especially) the generic
baseline.

* Tools/Scripts/webkitpy/w3c/test_importer.py:
(TestImporter.remove_dangling_expectations):
* Tools/Scripts/webkitpy/w3c/test_importer_unittest.py:
(TestImporterTest.import_downloaded_tests):

Canonical link: https://commits.webkit.org/270899@main
  • Loading branch information
gsnedders committed Nov 17, 2023
1 parent 579a9e5 commit 69c47f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Tools/Scripts/webkitpy/w3c/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,15 @@ def remove_dangling_expectations(self, filename):
#FIXME: Clean also the expected files stored in all platform specific folders.
directory = self.filesystem.join(self.destination_directory, filename)
tests = LayoutTestFinder(self.port, None).find_tests_by_path([directory])
baselines_for_tests = {self.port.expected_filename(test.test_path, '.txt') for test in tests}
baselines_for_tests = {
self.filesystem.join(
platform_dir or self.port.layout_tests_dir(), baseline_filename
)
for test in tests
for platform_dir, baseline_filename in self.port.expected_baselines(
test.test_path, ".txt", all_baselines=True
)
}
for relative_path in self.filesystem.files_under(directory, file_filter=self._is_baseline):
path = self.filesystem.join(directory, relative_path)
if path not in baselines_for_tests:
Expand Down
26 changes: 24 additions & 2 deletions Tools/Scripts/webkitpy/w3c/test_importer_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def import_directory(self, args, files, test_paths):
importer.do_import()
return host.filesystem

def import_downloaded_tests(self, args, files):
def import_downloaded_tests(self, args, files, test_port=False):
# files are passed as parameter as we cannot clone/fetch/checkout a repo in mock system.

class TestDownloaderMock(TestDownloader):
Expand All @@ -150,7 +150,10 @@ def _git_submodules_status(self, repository_directory):
return 'adb4d391a69877d4a1eaaf51d1725c99a5b8ed84 tools/resources'

host = MockHost()
port = host.port_factory.get()
if test_port:
port = TestPort(host)
else:
port = host.port_factory.get()
fs = host.filesystem
for path, contents in files.items():
fs.write_binary_file(path, contents)
Expand Down Expand Up @@ -632,3 +635,22 @@ def test_template_test_variant_dangling(self):
self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/variant.any_1-10-expected.txt'))
self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/variant.any_11-20-expected.txt'))
self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/variant.any_21-30-expected.txt'))

def test_non_dangling_platform(self):
FAKE_FILES = {
'/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/test.html': MINIMAL_TESTHARNESS,
'/test.checkout/LayoutTests/imported/w3c/resources/import-expectations.json': '{}',
'/test.checkout/LayoutTests/w3c/web-platform-tests/t/test.html': MINIMAL_TESTHARNESS,
'/test.checkout/LayoutTests/w3c/web-platform-tests/t/test-expected.txt': '1',
'/test.checkout/LayoutTests/platform/test-mac-leopard/w3c/web-platform-tests/t/test-expected.txt': '2',
'/test.checkout/LayoutTests/platform/test-linux-x86_64/w3c/web-platform-tests/t/test-expected.txt': '3',
'/test.checkout/LayoutTests/platform/unknown-platform/w3c/web-platform-tests/t/test-expected.txt': '4',
}

fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '--clean-dest-dir', '-d', 'w3c'], FAKE_FILES, test_port=True)

self.assertTrue(fs.exists('/test.checkout/LayoutTests/w3c/web-platform-tests/t/test.html'))
self.assertTrue(fs.exists('/test.checkout/LayoutTests/w3c/web-platform-tests/t/test-expected.txt'))
self.assertTrue(fs.exists('/test.checkout/LayoutTests/platform/test-mac-leopard/w3c/web-platform-tests/t/test-expected.txt'))
self.assertTrue(fs.exists('/test.checkout/LayoutTests/platform/test-linux-x86_64/w3c/web-platform-tests/t/test-expected.txt'))
self.assertTrue(fs.exists('/test.checkout/LayoutTests/platform/unknown-platform/w3c/web-platform-tests/t/test-expected.txt'))

0 comments on commit 69c47f8

Please sign in to comment.