Modified: trunk/Tools/ChangeLog (193637 => 193638)
--- trunk/Tools/ChangeLog 2015-12-07 18:35:56 UTC (rev 193637)
+++ trunk/Tools/ChangeLog 2015-12-07 18:49:59 UTC (rev 193638)
@@ -1,5 +1,25 @@
2015-12-07 Xabier Rodriguez Calvar <calva...@igalia.com>
+ Add support to import w3c tests from a repository with a different root that the main repo dir
+ https://bugs.webkit.org/show_bug.cgi?id=151751
+
+ Reviewed by Ryosuke Niwa and Youenn Fablet.
+
+ We should be able to import tests from repositories that are not pure test repositories and where tests are kept
+ in a different directory than the repository root.
+
+ This patch introduces a new parameter tests_directory that we will use as root directory to search for
+ tests. All paths will be flattened when copying tests to have a less complicated directory structure. This
+ requires having the copy_path lists including tuples of origin and destination directories.
+
+ * Scripts/webkitpy/w3c/test_downloader.py:
+ (TestDownloader._add_test_suite_paths): Adds the paths as a tuple of origin and destination directory.
+ (TestDownloader.copy_tests): Uses the origin and destination tuple for the paths to copy when copying files.
+ * Scripts/webkitpy/w3c/test_importer_unittest.py:
+ (TestImporterTest.test_tests_directory): Test.
+
+2015-12-07 Xabier Rodriguez Calvar <calva...@igalia.com>
+
Mock TestRepositories in W3C importer tests
https://bugs.webkit.org/show_bug.cgi?id=151938
Modified: trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py (193637 => 193638)
--- trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py 2015-12-07 18:35:56 UTC (rev 193637)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py 2015-12-07 18:49:59 UTC (rev 193638)
@@ -105,11 +105,12 @@
elif 'PASS' in line.expectations:
self.paths_to_import.append(line.name)
- def _add_test_suite_paths(self, test_paths, directory, webkit_path):
- for name in self._filesystem.listdir(directory):
- path = self._filesystem.join(webkit_path, name)
- if not name.startswith('.') and not path in self.paths_to_skip:
- test_paths.append(path)
+ def _add_test_suite_paths(self, test_paths, directory, webkit_path, tests_directory):
+ complete_directory = self._filesystem.join(directory, tests_directory)
+ for name in self._filesystem.listdir(complete_directory):
+ original_path = self._filesystem.join(webkit_path, tests_directory, name)
+ if not name.startswith('.') and not original_path in self.paths_to_skip:
+ test_paths.append((original_path, self._filesystem.join(webkit_path, name)))
def _empty_directory(self, directory):
if self._filesystem.exists(directory):
@@ -122,19 +123,22 @@
copy_paths = []
if test_paths:
- copy_paths.extend(test_paths)
- copy_paths.extend(self.paths_to_import)
+ for path in test_paths:
+ copy_paths.append((path, path))
+ for path in self.paths_to_import:
+ copy_paths.append((path, path))
else:
for test_repository in self.test_repositories:
- self._add_test_suite_paths(copy_paths, self._filesystem.join(self.repository_directory, test_repository['name']), test_repository['name'])
+ self._add_test_suite_paths(copy_paths, self._filesystem.join(self.repository_directory, test_repository['name']), test_repository['name'],
+ test_repository['tests_directory'] if ('tests_directory' in test_repository) else '')
# Handling of tests marked as [ Pass ] in expectations file.
for path in self.paths_to_import:
- if not path in copy_paths:
- copy_paths.append(path)
+ if not (path, path) in copy_paths:
+ copy_paths.append((path, path))
- for path in copy_paths:
- source_path = self._filesystem.join(self.repository_directory, path)
- destination_path = self._filesystem.join(destination_directory, path)
+ for paths in copy_paths:
+ source_path = self._filesystem.join(self.repository_directory, paths[0])
+ destination_path = self._filesystem.join(destination_directory, paths[1])
if not self._filesystem.exists(source_path):
_log.error('Cannot copy %s' % source_path)
elif self._filesystem.isdir(source_path):
Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py (193637 => 193638)
--- trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py 2015-12-07 18:35:56 UTC (rev 193637)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py 2015-12-07 18:49:59 UTC (rev 193638)
@@ -163,5 +163,27 @@
self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/resources/web-platform-tests-modules.json'))
# self.assertFalse('https://github.com/w3c/testharness.js/archive/db4d391a69877d4a1eaaf51d1725c99a5b8ed84.tar.gz' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/resources/web-platform-tests-modules.json'))
+ def test_tests_directory(self):
+ FAKE_FILES = {
+ '/mock-checkout/WebKitBuild/w3c-tests/streams-api/reference-implementation/web-platform-tests/test.html': '<!doctype html><script src="" src=""
+ '/mock-checkout/LayoutTests/imported/w3c/resources/TestRepositories': '''
+[
+ {
+ "name": "streams-api",
+ "url": "https://github.com/whatwg/streams.git",
+ "revision": "7cc96dd",
+ "tests_directory": "reference-implementation/web-platform-tests",
+ "paths_to_skip": [],
+ "paths_to_import": [],
+ "import_options": []
+ }
+]
+'''}
+ fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
+
+ self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/streams-api/reference-implementation/web-platform-tests/test.html'))
+ self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/streams-api/test.html'))
+
+
# FIXME: Needs more tests.