Title: [202340] trunk
Revision
202340
Author
[email protected]
Date
2016-06-22 11:20:31 -0700 (Wed, 22 Jun 2016)

Log Message

W3C test importer should generate files to ignore by WebKit SCM
https://bugs.webkit.org/show_bug.cgi?id=142743

Patch by Youenn Fablet <[email protected]> on 2016-06-22
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* resources/TestRepositories: Added the option to generate .gitignore and __init__.py for wpt repo.
* web-platform-tests/.gitignore: Regeneration changes the order of the ignored files and removes the __init__.py which is now committed to WebKit trunk.
* web-platform-tests/__init__.py: Added.

Tools:

TestDownloader generates the .gitignore file according submodules git repository information.
TestImporter requests the generation of .gitignore and the main __init__.py according LayoutTests/imported/w3c/resources/TestRepositories options.

* Scripts/webkitpy/w3c/test_downloader.py:
(TestDownloader.generate_gitignore): Generating .gitignore according submodules description.
* Scripts/webkitpy/w3c/test_importer.py:
(TestImporter.process_test_repositories_import_options): Added the generation of .gitignore/__init__.py if the repo has the right option.
(TestImporter):
(TestImporter.write_init_py): Writing not empty __init__.py files.
(TestImporter.import_tests): Using  of write_init_py.
* Scripts/webkitpy/w3c/test_importer_unittest.py:
(TestImporterTest.test_git_ignore_generation): Added .gitignore test.
(TestImporterTest):
(TestImporterTest.test_initpy_generation): Added __init__.py test.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (202339 => 202340)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-06-22 18:20:31 UTC (rev 202340)
@@ -1,3 +1,14 @@
+2016-06-22  Youenn Fablet  <[email protected]>
+
+        W3C test importer should generate files to ignore by WebKit SCM
+        https://bugs.webkit.org/show_bug.cgi?id=142743
+
+        Reviewed by Darin Adler.
+
+        * resources/TestRepositories: Added the option to generate .gitignore and __init__.py for wpt repo.
+        * web-platform-tests/.gitignore: Regeneration changes the order of the ignored files and removes the __init__.py which is now committed to WebKit trunk.
+        * web-platform-tests/__init__.py: Added.
+
 2016-06-22  Youenn Fablet  <[email protected]>
 
         imported/w3c/web-platform-tests/streams/readable-streams/general.https.html is a flaky failure

Modified: trunk/LayoutTests/imported/w3c/resources/TestRepositories (202339 => 202340)


--- trunk/LayoutTests/imported/w3c/resources/TestRepositories	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/LayoutTests/imported/w3c/resources/TestRepositories	2016-06-22 18:20:31 UTC (rev 202340)
@@ -30,6 +30,6 @@
             "config.default.json",
             "serve.py"
         ],
-        "import_options": ["generate_git_submodules_description"]
+        "import_options": ["generate_git_submodules_description", "generate_gitignore"]
     }
 ]

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/.gitignore (202339 => 202340)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/.gitignore	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/.gitignore	2016-06-22 18:20:31 UTC (rev 202340)
@@ -1,7 +1,22 @@
+/resources/
 /.resources.url
-/__init__.py
-
-/resources/
-
+/resources/webidl2/
+/resources/.webidl2.url
+/resources/webidl2/test/widlproc/
+/resources/webidl2/test/.widlproc.url
+/tools/
 /.tools.url
-/tools/
+/tools/html5lib/
+/tools/.html5lib.url
+/tools/html5lib/html5lib/tests/testdata/
+/tools/html5lib/html5lib/tests/.testdata.url
+/tools/pytest/
+/tools/.pytest.url
+/tools/pywebsocket/
+/tools/.pywebsocket.url
+/tools/six/
+/tools/.six.url
+/tools/webdriver/
+/tools/.webdriver.url
+/tools/wptserve/
+/tools/.wptserve.url
\ No newline at end of file

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/__init__.py (0 => 202340)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/__init__.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/__init__.py	2016-06-22 18:20:31 UTC (rev 202340)
@@ -0,0 +1 @@
+# This file is required for Python to search this directory for modules.

Modified: trunk/Tools/ChangeLog (202339 => 202340)


--- trunk/Tools/ChangeLog	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/Tools/ChangeLog	2016-06-22 18:20:31 UTC (rev 202340)
@@ -1,3 +1,25 @@
+2016-06-22  Youenn Fablet  <[email protected]>
+
+        W3C test importer should generate files to ignore by WebKit SCM
+        https://bugs.webkit.org/show_bug.cgi?id=142743
+
+        Reviewed by Darin Adler.
+
+        TestDownloader generates the .gitignore file according submodules git repository information.
+        TestImporter requests the generation of .gitignore and the main __init__.py according LayoutTests/imported/w3c/resources/TestRepositories options.
+
+        * Scripts/webkitpy/w3c/test_downloader.py:
+        (TestDownloader.generate_gitignore): Generating .gitignore according submodules description.
+        * Scripts/webkitpy/w3c/test_importer.py:
+        (TestImporter.process_test_repositories_import_options): Added the generation of .gitignore/__init__.py if the repo has the right option.
+        (TestImporter):
+        (TestImporter.write_init_py): Writing not empty __init__.py files.
+        (TestImporter.import_tests): Using  of write_init_py. 
+        * Scripts/webkitpy/w3c/test_importer_unittest.py:
+        (TestImporterTest.test_git_ignore_generation): Added .gitignore test.
+        (TestImporterTest):
+        (TestImporterTest.test_initpy_generation): Added __init__.py test.
+
 2016-06-21  Sam Weinig  <[email protected]>
 
         WKWebView with no WKNavigationDelegate does not follow universal links

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py (202339 => 202340)


--- trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py	2016-06-22 18:20:31 UTC (rev 202340)
@@ -31,7 +31,6 @@
 import json
 import logging
 
-from webkitpy.common.system.executive import Executive
 from webkitpy.common.system.filesystem import FileSystem
 from webkitpy.common.webkit_finder import WebKitFinder
 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
@@ -184,6 +183,15 @@
     def generate_git_submodules_description(self, test_repository, filepath):
         self._filesystem.write_text_file(filepath, json.dumps(self._git_submodules_description(test_repository), sort_keys=True, indent=4))
 
+    def generate_gitignore(self, test_repository, destination_directory):
+        rules = []
+        for submodule in self._git_submodules_description(test_repository):
+            path = list(submodule['path'])
+            path.insert(0, '')
+            rules.append('/'.join(path[:-1]) + '/' + path[-1] + '/')
+            rules.append('/'.join(path[:-1]) + '/.' + path[-1] + '.url')
+        self._filesystem.write_text_file(self._filesystem.join(destination_directory, test_repository['name'], '.gitignore'), '\n'.join(rules))
+
     def download_tests(self, destination_directory, test_paths=[]):
         for test_repository in self.test_repositories:
             self.checkout_test_repository(test_repository['revision'], test_repository['url'], self._filesystem.join(self.repository_directory, test_repository['name']))

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer.py (202339 => 202340)


--- trunk/Tools/Scripts/webkitpy/w3c/test_importer.py	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer.py	2016-06-22 18:20:31 UTC (rev 202340)
@@ -210,8 +210,14 @@
             if 'generate_git_submodules_description' in test_repository['import_options']:
                 self.filesystem.maybe_make_directory(self.filesystem.join(self.destination_directory, 'resources'))
                 self._test_downloader.generate_git_submodules_description(test_repository, self.filesystem.join(self.destination_directory, 'resources', test_repository['name'] + '-modules.json'))
-            # FIXME: Generate WPT .gitignore and  main __init__.py
+            if 'generate_gitignore' in test_repository['import_options']:
+                self._test_downloader.generate_gitignore(test_repository, self.destination_directory)
+            if 'generate_init_py' in test_repository['import_options']:
+                self.write_init_py(self.filesystem.join(self.destination_directory, test_repository['name'], '__init__.py'))
 
+    def write_init_py(self, filepath):
+        self.filesystem.write_text_file(filepath, '# This file is required for Python to search this directory for modules.')
+
     def test_downloader(self):
         if not self._test_downloader:
             download_options = TestDownloader.default_options()
@@ -428,7 +434,7 @@
                         self.filesystem.write_binary_file(new_filepath, converted_file[2])
                 elif orig_filepath.endswith('__init__.py') and not self.filesystem.getsize(orig_filepath):
                     # Some bots dislike empty __init__.py.
-                    self.filesystem.write_text_file(new_filepath, '# This file is required for Python to search this directory for modules.')
+                    self.write_init_py(new_filepath)
                 else:
                     self.filesystem.copyfile(orig_filepath, new_filepath)
 

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py (202339 => 202340)


--- trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py	2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py	2016-06-22 18:20:31 UTC (rev 202340)
@@ -25,9 +25,6 @@
 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 
-import optparse
-import shutil
-import tempfile
 import unittest
 
 from webkitpy.common.host_mock import MockHost
@@ -37,7 +34,6 @@
 from webkitpy.w3c.test_downloader import TestDownloader
 from webkitpy.w3c.test_importer import parse_args, TestImporter
 
-
 FAKE_SOURCE_DIR = '/tests/csswg'
 FAKE_TEST_PATH = 'css-fake-1'
 
@@ -63,7 +59,7 @@
         "revision": "dd553279c3",
         "paths_to_skip": [],
         "paths_to_import": [],
-        "import_options": ["generate_git_submodules_description"]
+        "import_options": ["generate_git_submodules_description", "generate_gitignore", "generate_init_py"]
     }
 ]
 ''' }
@@ -214,4 +210,38 @@
         self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
         self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.svn'))
 
+    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 = ""  ignore = dirty\n',
+            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = ""  ignore = dirty\n',
+        }
+
+        FAKE_FILES.update(FAKE_REPOSITORY)
+
+        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
+
+        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/csswg-tests/.gitignore'))
+        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
+        # We should activate these lines but this is not working in mock systems.
+        #self.assertTrue('/tools/.resources.url' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
+        #self.assertTrue('/tools/resources/' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
+
+    def test_initpy_generation(self):
+        FAKE_FILES = {
+            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = ""  ignore = dirty\n',
+            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule "tools/resources"]\n	path = tools/resources\n	url = ""  ignore = dirty\n',
+        }
+
+        FAKE_FILES.update(FAKE_REPOSITORY)
+
+        host = MockHost()
+        host.executive = MockExecutive2()
+        host.filesystem = MockFileSystem(files=FAKE_FILES)
+
+        fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
+
+        self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/csswg-tests/__init__.py'))
+        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py'))
+        self.assertTrue(fs.getsize('/mock-checkout/LayoutTests/w3c/web-platform-tests/__init__.py') > 0)
+
     # FIXME: Needs more tests.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to