import-w3c-tests should respect WEBKIT_OUTPUTDIR
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jun 2019 15:53:55 +0000 (15:53 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jun 2019 15:53:55 +0000 (15:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198682
<rdar://problem/51536931>

Reviewed by Jonathan Bedard.

Check for WEBKIT_OUTPUTDIR environment variable to compute the w3c-tests folder.
Made some refactoring to also teach WPTPaths users about WEBKIT_OUTPUTDIR.

* Scripts/webkitpy/common/webkit_finder.py:
(WebKitFinder.path_from_webkit_outputdir):
* Scripts/webkitpy/w3c/common.py:
(WPTPaths):
(WPTPaths.checkout_directory):
(WPTPaths.wpt_checkout_path):
* Scripts/webkitpy/w3c/test_importer.py:
(TestImporter.__init__):
* Scripts/webkitpy/w3c/test_importer_unittest.py:
(test_checkout_directory):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246434 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/webkit_finder.py
Tools/Scripts/webkitpy/w3c/common.py
Tools/Scripts/webkitpy/w3c/test_importer.py
Tools/Scripts/webkitpy/w3c/test_importer_unittest.py

index 597593a..e3aa4e9 100644 (file)
@@ -1,3 +1,25 @@
+2019-06-14  Youenn Fablet  <youenn@apple.com>
+
+        import-w3c-tests should respect WEBKIT_OUTPUTDIR
+        https://bugs.webkit.org/show_bug.cgi?id=198682
+        <rdar://problem/51536931>
+
+        Reviewed by Jonathan Bedard.
+
+        Check for WEBKIT_OUTPUTDIR environment variable to compute the w3c-tests folder.
+        Made some refactoring to also teach WPTPaths users about WEBKIT_OUTPUTDIR.
+
+        * Scripts/webkitpy/common/webkit_finder.py:
+        (WebKitFinder.path_from_webkit_outputdir):
+        * Scripts/webkitpy/w3c/common.py:
+        (WPTPaths):
+        (WPTPaths.checkout_directory):
+        (WPTPaths.wpt_checkout_path):
+        * Scripts/webkitpy/w3c/test_importer.py:
+        (TestImporter.__init__):
+        * Scripts/webkitpy/w3c/test_importer_unittest.py:
+        (test_checkout_directory):
+
 2019-06-13  Antoine Quint  <graouts@apple.com>
 
         REGRESSION (r246103) [ Mojave+ WK1 ] Layout Test scrollbars/scrollbar-iframe-click-does-not-blur-content.html is timing out
index 7b9c014..7d7f9e1 100644 (file)
@@ -26,6 +26,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import os
+
 
 class WebKitFinder(object):
     def __init__(self, filesystem):
@@ -52,6 +54,10 @@ class WebKitFinder(object):
     def path_from_webkit_base(self, *comps):
         return self._filesystem.join(self.webkit_base(), *comps)
 
+    def path_from_webkit_outputdir(self, *comps):
+        base_path = os.environ['WEBKIT_OUTPUTDIR'] if 'WEBKIT_OUTPUTDIR' in os.environ else self.path_from_webkit_base('WebKitBuild')
+        return self._filesystem.join(base_path, *comps)
+
     def path_to_script(self, script_name):
         """Returns the relative path to the script from the top of the WebKit tree."""
         # This is intentionally relative in order to force callers to consider what
index f823cfa..848b04f 100644 (file)
@@ -101,13 +101,13 @@ def is_file_exportable(path):
 
 
 class WPTPaths:
-    CHECKOUT_DIRECTORY = ["WebKitBuild", "w3c-tests"]
+    CHECKOUT_DIRECTORY = ["w3c-tests"]
     WPT_CHECKOUT_PATH = CHECKOUT_DIRECTORY + ["web-platform-tests"]
 
     @staticmethod
     def checkout_directory(finder):
-        return finder.path_from_webkit_base(*WPTPaths.CHECKOUT_DIRECTORY)
+        return finder.path_from_webkit_outputdir(*WPTPaths.CHECKOUT_DIRECTORY)
 
     @staticmethod
     def wpt_checkout_path(finder):
-        return finder.path_from_webkit_base(*WPTPaths.WPT_CHECKOUT_PATH)
+        return finder.path_from_webkit_outputdir(*WPTPaths.WPT_CHECKOUT_PATH)
index e874808..8ee5628 100644 (file)
@@ -79,7 +79,7 @@ import mimetypes
 from webkitpy.common.host import Host
 from webkitpy.common.system.filesystem import FileSystem
 from webkitpy.common.webkit_finder import WebKitFinder
-from webkitpy.w3c.common import WPT_GH_URL
+from webkitpy.w3c.common import WPT_GH_URL, WPTPaths
 from webkitpy.w3c.test_parser import TestParser
 from webkitpy.w3c.test_converter import convert_for_webkit
 from webkitpy.w3c.test_downloader import TestDownloader
@@ -169,7 +169,7 @@ class TestImporter(object):
         self.tests_w3c_relative_path = self.filesystem.join('imported', 'w3c')
         self.layout_tests_path = webkit_finder.path_from_webkit_base('LayoutTests')
         self.layout_tests_w3c_path = self.filesystem.join(self.layout_tests_path, self.tests_w3c_relative_path)
-        self.tests_download_path = webkit_finder.path_from_webkit_base('WebKitBuild', 'w3c-tests')
+        self.tests_download_path = WPTPaths.checkout_directory(webkit_finder)
 
         self._test_downloader = None
 
index 7b64298..3177890 100644 (file)
@@ -25,6 +25,7 @@
 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 
+import os
 import unittest
 
 from webkitpy.common.host_mock import MockHost
@@ -209,6 +210,22 @@ class TestImporterTest(unittest.TestCase):
         self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/dir-to-skip/dir-to-not-import/test-to-not-import.html'))
         self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/dir-to-skip/test-to-skip.html'))
 
+    def test_checkout_directory(self):
+        FAKE_FILES = {
+            '/mock-checkout/WebKitBuild2/w3c-tests/web-platform-tests/existing-test.html': '',
+            '/mock-checkout/WebKitBuild2/w3c-tests/csswg-tests/test.html': '1',
+        }
+
+        FAKE_FILES.update(FAKE_REPOSITORY)
+
+        os.environ['WEBKIT_OUTPUTDIR'] = '/mock-checkout/WebKitBuild2'
+        try:
+            fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES)
+        finally:
+            del os.environ['WEBKIT_OUTPUTDIR']
+
+        self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/existing-test.html'))
+
     def test_clean_directory_option(self):
         FAKE_FILES = {
             '/mock-checkout/LayoutTests/w3c/web-platform-tests/.gitattributes': '-1',