<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202340] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202340">202340</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-22 11:20:31 -0700 (Wed, 22 Jun 2016)</dd>
</dl>

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

Patch by Youenn Fablet &lt;youenn.fablet@crf.canon.fr&gt; 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cresourcesTestRepositories">trunk/LayoutTests/imported/w3c/resources/TestRepositories</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsgitignore">trunk/LayoutTests/imported/w3c/web-platform-tests/.gitignore</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpyw3ctest_downloaderpy">trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyw3ctest_importerpy">trunk/Tools/Scripts/webkitpy/w3c/test_importer.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyw3ctest_importer_unittestpy">trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtests__init__py">trunk/LayoutTests/imported/w3c/web-platform-tests/__init__.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-06-22  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        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.
+
</ins><span class="cx"> 2016-06-22  Youenn Fablet  &lt;youennf@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         imported/w3c/web-platform-tests/streams/readable-streams/general.https.html is a flaky failure
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cresourcesTestRepositories"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/resources/TestRepositories (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -30,6 +30,6 @@
</span><span class="cx">             &quot;config.default.json&quot;,
</span><span class="cx">             &quot;serve.py&quot;
</span><span class="cx">         ],
</span><del>-        &quot;import_options&quot;: [&quot;generate_git_submodules_description&quot;]
</del><ins>+        &quot;import_options&quot;: [&quot;generate_git_submodules_description&quot;, &quot;generate_gitignore&quot;]
</ins><span class="cx">     }
</span><span class="cx"> ]
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsgitignore"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/.gitignore (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,7 +1,22 @@
</span><ins>+/resources/
</ins><span class="cx"> /.resources.url
</span><del>-/__init__.py
-
-/resources/
-
</del><ins>+/resources/webidl2/
+/resources/.webidl2.url
+/resources/webidl2/test/widlproc/
+/resources/webidl2/test/.widlproc.url
+/tools/
</ins><span class="cx"> /.tools.url
</span><del>-/tools/
</del><ins>+/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
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtests__init__py"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/__init__.py (0 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+# This file is required for Python to search this directory for modules.
</ins></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-06-22 18:15:40 UTC (rev 202339)
+++ trunk/Tools/ChangeLog        2016-06-22 18:20:31 UTC (rev 202340)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-06-22  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        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.
+
</ins><span class="cx"> 2016-06-21  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         WKWebView with no WKNavigationDelegate does not follow universal links
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyw3ctest_downloaderpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/w3c/test_downloader.py (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> import json
</span><span class="cx"> import logging
</span><span class="cx"> 
</span><del>-from webkitpy.common.system.executive import Executive
</del><span class="cx"> from webkitpy.common.system.filesystem import FileSystem
</span><span class="cx"> from webkitpy.common.webkit_finder import WebKitFinder
</span><span class="cx"> from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
</span><span class="lines">@@ -184,6 +183,15 @@
</span><span class="cx">     def generate_git_submodules_description(self, test_repository, filepath):
</span><span class="cx">         self._filesystem.write_text_file(filepath, json.dumps(self._git_submodules_description(test_repository), sort_keys=True, indent=4))
</span><span class="cx"> 
</span><ins>+    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))
+
</ins><span class="cx">     def download_tests(self, destination_directory, test_paths=[]):
</span><span class="cx">         for test_repository in self.test_repositories:
</span><span class="cx">             self.checkout_test_repository(test_repository['revision'], test_repository['url'], self._filesystem.join(self.repository_directory, test_repository['name']))
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyw3ctest_importerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer.py (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -210,8 +210,14 @@
</span><span class="cx">             if 'generate_git_submodules_description' in test_repository['import_options']:
</span><span class="cx">                 self.filesystem.maybe_make_directory(self.filesystem.join(self.destination_directory, 'resources'))
</span><span class="cx">                 self._test_downloader.generate_git_submodules_description(test_repository, self.filesystem.join(self.destination_directory, 'resources', test_repository['name'] + '-modules.json'))
</span><del>-            # FIXME: Generate WPT .gitignore and  main __init__.py
</del><ins>+            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'))
</ins><span class="cx"> 
</span><ins>+    def write_init_py(self, filepath):
+        self.filesystem.write_text_file(filepath, '# This file is required for Python to search this directory for modules.')
+
</ins><span class="cx">     def test_downloader(self):
</span><span class="cx">         if not self._test_downloader:
</span><span class="cx">             download_options = TestDownloader.default_options()
</span><span class="lines">@@ -428,7 +434,7 @@
</span><span class="cx">                         self.filesystem.write_binary_file(new_filepath, converted_file[2])
</span><span class="cx">                 elif orig_filepath.endswith('__init__.py') and not self.filesystem.getsize(orig_filepath):
</span><span class="cx">                     # Some bots dislike empty __init__.py.
</span><del>-                    self.filesystem.write_text_file(new_filepath, '# This file is required for Python to search this directory for modules.')
</del><ins>+                    self.write_init_py(new_filepath)
</ins><span class="cx">                 else:
</span><span class="cx">                     self.filesystem.copyfile(orig_filepath, new_filepath)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyw3ctest_importer_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py (202339 => 202340)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -25,9 +25,6 @@
</span><span class="cx"> # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
</span><span class="cx"> # SUCH DAMAGE.
</span><span class="cx"> 
</span><del>-import optparse
-import shutil
-import tempfile
</del><span class="cx"> import unittest
</span><span class="cx"> 
</span><span class="cx"> from webkitpy.common.host_mock import MockHost
</span><span class="lines">@@ -37,7 +34,6 @@
</span><span class="cx"> from webkitpy.w3c.test_downloader import TestDownloader
</span><span class="cx"> from webkitpy.w3c.test_importer import parse_args, TestImporter
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> FAKE_SOURCE_DIR = '/tests/csswg'
</span><span class="cx"> FAKE_TEST_PATH = 'css-fake-1'
</span><span class="cx"> 
</span><span class="lines">@@ -63,7 +59,7 @@
</span><span class="cx">         &quot;revision&quot;: &quot;dd553279c3&quot;,
</span><span class="cx">         &quot;paths_to_skip&quot;: [],
</span><span class="cx">         &quot;paths_to_import&quot;: [],
</span><del>-        &quot;import_options&quot;: [&quot;generate_git_submodules_description&quot;]
</del><ins>+        &quot;import_options&quot;: [&quot;generate_git_submodules_description&quot;, &quot;generate_gitignore&quot;, &quot;generate_init_py&quot;]
</ins><span class="cx">     }
</span><span class="cx"> ]
</span><span class="cx"> ''' }
</span><span class="lines">@@ -214,4 +210,38 @@
</span><span class="cx">         self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitignore'))
</span><span class="cx">         self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/.svn'))
</span><span class="cx"> 
</span><ins>+    def test_git_ignore_generation(self):
+        FAKE_FILES = {
+            '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/.gitmodules': '[submodule &quot;tools/resources&quot;]\n        path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
+            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule &quot;tools/resources&quot;]\n        path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  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 &quot;tools/resources&quot;]\n        path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  ignore = dirty\n',
+            '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/.gitmodules': '[submodule &quot;tools/resources&quot;]\n        path = tools/resources\n        url = https://github.com/w3c/testharness.js.git\n  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') &gt; 0)
+
</ins><span class="cx">     # FIXME: Needs more tests.
</span></span></pre>
</div>
</div>

</body>
</html>