Skip to content

Commit

Permalink
[import-w3c-tests] Avoid changing test metadata files based on direct…
Browse files Browse the repository at this point in the history
…ory suffixes

https://bugs.webkit.org/show_bug.cgi?id=257855
rdar://problem/110845019

Reviewed by Jonathan Bedard.

Previously, when updating web-platform-tests/cssom, we would
accidentally make metadata updates for web-platform-tests/cssom-view
(and believe that that directory was now empty, given we hadn't
imported anything for it).

* Tools/Scripts/webkitpy/w3c/test_importer.py:
(TestImporter.do_import):
* Tools/Scripts/webkitpy/w3c/test_importer_unittest.py:

Canonical link: https://commits.webkit.org/265841@main
  • Loading branch information
gsnedders committed Jul 7, 2023
1 parent 93742b8 commit 90b3991
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Tools/Scripts/webkitpy/w3c/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def do_import(self):
for test_path in test_paths:
self.clean_destination_directory(test_path)
if self._test_resource_files:
test_paths_tuple = tuple(test_paths)
test_paths_tuple = tuple(p.rstrip(self.filesystem.sep) + self.filesystem.sep for p in test_paths)
self._test_resource_files["files"] = [t for t in self._test_resource_files["files"]
if not t.startswith(test_paths_tuple)]
if self._tests_options:
Expand Down
49 changes: 49 additions & 0 deletions Tools/Scripts/webkitpy/w3c/test_importer_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,55 @@ def test_clean_directory_option_partial_import(self):
self.assertIn("imported/w3c/web-platform-tests/a/old-test.html", tests_options)
self.assertNotIn("imported/w3c/web-platform-tests/b/old-test.html", tests_options)

def test_clean_directory_option_prefix_name(self):
existing_resource_files = {
"directories": [],
"files": [
"web-platform-tests/cssom-view/old-support.html",
"web-platform-tests/cssom/old-support.html",
"web-platform-tests/cssom/existing-support.html",
],
}
existing_tests_options = {
"imported/w3c/web-platform-tests/cssom-view/old-test.html": ["slow"],
"imported/w3c/web-platform-tests/cssom/old-test.html": ["slow"],
"imported/w3c/web-platform-tests/cssom/existing-test.html": ["slow"],
}

FAKE_FILES = {
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom-view/old-test.html': '1',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom-view/old-test-expected.txt': '2',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom-view/old-support.html': '3',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/old-test.html': '4',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/old-test-expected.txt': '5',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/old-support.html': '6',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/existing-test.html': '4',
'/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/existing-test-expected.txt': '5',
'/mock-checkout/LayoutTests/imported/w3c/resources/resource-files.json': json.dumps(existing_resource_files),
'/mock-checkout/LayoutTests/tests-options.json': json.dumps(existing_tests_options),
'/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/cssom/existing-test.html': MINIMAL_TESTHARNESS,
'/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/test.html': '-1',
}

FAKE_FILES.update(FAKE_REPOSITORIES)

fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '--clean-dest-dir', 'web-platform-tests/cssom'], FAKE_FILES)

self.assertTrue(fs.exists('/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom-view/old-test.html'))
self.assertTrue(fs.exists('/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom-view/old-test-expected.txt'))
self.assertFalse(fs.exists('/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/old-test.html'))
self.assertFalse(fs.exists('/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/old-test-expected.txt'))
self.assertTrue(fs.exists('/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/existing-test.html'))
self.assertTrue(fs.exists('/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/cssom/existing-test-expected.txt'))

resource_files = json.loads(fs.read_text_file('/mock-checkout/LayoutTests/imported/w3c/resources/resource-files.json'))
self.assertIn("web-platform-tests/cssom-view/old-support.html", resource_files["files"])
self.assertNotIn("web-platform-tests/cssom/old-support.html", resource_files["files"])

tests_options = json.loads(fs.read_text_file('/mock-checkout/LayoutTests/tests-options.json'))
self.assertIn("imported/w3c/web-platform-tests/cssom-view/old-test.html", tests_options)
self.assertNotIn("imported/w3c/web-platform-tests/cssom/old-test.html", tests_options)

def test_git_ignore_generation(self):
FAKE_FILES = {
'/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule "tools/resources"]\n path = tools/resources\n url = https://github.com/w3c/testharness.js.git\n ignore = dirty\n',
Expand Down

0 comments on commit 90b3991

Please sign in to comment.