Title: [221079] trunk/Tools
Revision
221079
Author
[email protected]
Date
2017-08-23 10:04:25 -0700 (Wed, 23 Aug 2017)

Log Message

Access expectations path through apple_additions
https://bugs.webkit.org/show_bug.cgi?id=174800
<rdar://problem/33498899>

Reviewed by Alexey Proskuryakov.

When external test expectations are imported through additional-platform-directory, they will
over-write any WebKit expectations. Access some expectations from apple_additions to correct
these precedence issues.

* Scripts/webkitpy/port/ios.py:
(IOSPort._apple_additions_path): Convert test expectation directory to a path
coming from apple_additions.
(IOSPort.default_baseline_search_path): Alternate between WebKit path and apple_additions
path for layout test expectations.
* Scripts/webkitpy/port/ios_device_unittest.py:
(IOSDeviceTest.test_layout_test_searchpath_with_apple_additions): Added to test layout-test search paths.
* Scripts/webkitpy/port/ios_simulator_unittest.py:
(IOSSimulatorTest.test_layout_test_searchpath_with_apple_additions): Added to test layout-test search paths.
* Scripts/webkitpy/port/mac.py:
(MacPort._apple_additions_path): Convert test expectation directory to a path
coming from apple_additions.
(MacPort.default_baseline_search_path): Alternate between WebKit path and apple_additions
path for layout test expectations.
* Scripts/webkitpy/port/mac_unittest.py:
(MacTest.test_layout_test_searchpath_with_apple_additions): Added to test layout-test search paths.
* Scripts/webkitpy/port/port_testcase.py:
(bind_mock_apple_additions): Added to create mock apple_additions for a block.
(bind_mock_apple_additions.MockAppleAdditions): Contains apple_addition stubs for testing.
* Scripts/webkitpy/port/win.py:
(WinPort.default_baseline_search_path): Include apple_additions test expectation for Windows.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (221078 => 221079)


--- trunk/Tools/ChangeLog	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/ChangeLog	2017-08-23 17:04:25 UTC (rev 221079)
@@ -1,3 +1,37 @@
+2017-08-23  Jonathan Bedard  <[email protected]>
+
+        Access expectations path through apple_additions
+        https://bugs.webkit.org/show_bug.cgi?id=174800
+        <rdar://problem/33498899>
+
+        Reviewed by Alexey Proskuryakov.
+
+        When external test expectations are imported through additional-platform-directory, they will
+        over-write any WebKit expectations. Access some expectations from apple_additions to correct
+        these precedence issues.
+
+        * Scripts/webkitpy/port/ios.py:
+        (IOSPort._apple_additions_path): Convert test expectation directory to a path
+        coming from apple_additions.
+        (IOSPort.default_baseline_search_path): Alternate between WebKit path and apple_additions
+        path for layout test expectations.
+        * Scripts/webkitpy/port/ios_device_unittest.py:
+        (IOSDeviceTest.test_layout_test_searchpath_with_apple_additions): Added to test layout-test search paths.
+        * Scripts/webkitpy/port/ios_simulator_unittest.py:
+        (IOSSimulatorTest.test_layout_test_searchpath_with_apple_additions): Added to test layout-test search paths.
+        * Scripts/webkitpy/port/mac.py:
+        (MacPort._apple_additions_path): Convert test expectation directory to a path
+        coming from apple_additions.
+        (MacPort.default_baseline_search_path): Alternate between WebKit path and apple_additions
+        path for layout test expectations.
+        * Scripts/webkitpy/port/mac_unittest.py:
+        (MacTest.test_layout_test_searchpath_with_apple_additions): Added to test layout-test search paths.
+        * Scripts/webkitpy/port/port_testcase.py:
+        (bind_mock_apple_additions): Added to create mock apple_additions for a block.
+        (bind_mock_apple_additions.MockAppleAdditions): Contains apple_addition stubs for testing.
+        * Scripts/webkitpy/port/win.py:
+        (WinPort.default_baseline_search_path): Include apple_additions test expectation for Windows.
+
 2017-08-22  Zan Dobersek  <[email protected]>
 
         Unreviewed. The WPE port should build TestWebKitAPI with the same

Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/ios.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -25,6 +25,7 @@
 
 from webkitpy.common.memoized import memoized
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
+from webkitpy.port.config import apple_additions
 from webkitpy.port.darwin import DarwinPort
 from webkitpy.port.simulator_process import SimulatorProcess
 
@@ -86,11 +87,25 @@
             return self._testing_device(worker_number)
         return self._current_device
 
+    def _apple_additions_path(self, name):
+        if name == 'wk2':
+            return None
+        split_name = name.split('-')
+        if len(split_name) > 1 and split_name[1] != 'wk1' and split_name[1] != 'wk2' and split_name[1] != 'simulator' and split_name[1] != 'device':
+            os_name = apple_additions().ios_os_name(split_name[1])
+            if not os_name:
+                return None
+            name = split_name[0] + '-' + os_name + ('-' + '-'.join(split_name[2:]) if len(split_name) > 2 else '')
+        return self._filesystem.join(apple_additions().layout_tests_path(), name)
+
+    @memoized
     def default_baseline_search_path(self):
         wk_string = 'wk1'
         if self.get_option('webkit_test_runner'):
             wk_string = 'wk2'
         fallback_names = [
+            '{}-{}-{}'.format(self.port_name, self.ios_version().split('.')[0], wk_string),
+            '{}-{}'.format(self.port_name, self.ios_version().split('.')[0]),
             '{}-{}'.format(self.port_name, wk_string),
             self.port_name,
             '{}-{}'.format(IOSPort.port_name, self.ios_version().split('.')[0]),
@@ -100,7 +115,16 @@
         if self.get_option('webkit_test_runner'):
             fallback_names.append('wk2')
 
-        return map(self._webkit_baseline_path, fallback_names)
+        webkit_expectations = map(self._webkit_baseline_path, fallback_names)
+        if apple_additions() and getattr(apple_additions(), "layout_tests_path", None):
+            apple_expectations = map(self._apple_additions_path, fallback_names)
+            result = []
+            for i in xrange(len(webkit_expectations)):
+                if apple_expectations[i]:
+                    result.append(apple_expectations[i])
+                result.append(webkit_expectations[i])
+            return result
+        return webkit_expectations
 
     def test_expectations_file_position(self):
         return 4

Modified: trunk/Tools/Scripts/webkitpy/port/ios_device_unittest.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/ios_device_unittest.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/ios_device_unittest.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -26,6 +26,7 @@
 from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
 from webkitpy.port.ios_device import IOSDevicePort
 from webkitpy.port import ios_testcase
+from webkitpy.port import port_testcase
 
 
 class IOSDeviceTest(ios_testcase.IOSTest):
@@ -88,3 +89,19 @@
         port = self.make_port(port_name=self.port_name)
         with self.assertRaises(RuntimeError):
             port._get_crash_log('DumpRenderTree', 1234, None, None, time.time(), wait_for_log=False)
+
+    def test_layout_test_searchpath_with_apple_additions(self):
+        with port_testcase.bind_mock_apple_additions():
+            search_path = self.make_port().default_baseline_search_path()
+        self.assertEqual(search_path[0], '/additional_testing_path/ios-device-11-wk1')
+        self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/ios-device-11-wk1')
+        self.assertEqual(search_path[2], '/additional_testing_path/ios-device-11')
+        self.assertEqual(search_path[3], '/mock-checkout/LayoutTests/platform/ios-device-11')
+        self.assertEqual(search_path[4], '/additional_testing_path/ios-device-wk1')
+        self.assertEqual(search_path[5], '/mock-checkout/LayoutTests/platform/ios-device-wk1')
+        self.assertEqual(search_path[6], '/additional_testing_path/ios-device')
+        self.assertEqual(search_path[7], '/mock-checkout/LayoutTests/platform/ios-device')
+        self.assertEqual(search_path[8], '/additional_testing_path/ios-11')
+        self.assertEqual(search_path[9], '/mock-checkout/LayoutTests/platform/ios-11')
+        self.assertEqual(search_path[10], '/additional_testing_path/ios-wk1')
+        self.assertEqual(search_path[11], '/mock-checkout/LayoutTests/platform/ios-wk1')

Modified: trunk/Tools/Scripts/webkitpy/port/ios_simulator_unittest.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/ios_simulator_unittest.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/ios_simulator_unittest.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -24,6 +24,7 @@
 
 from webkitpy.port.ios_simulator import IOSSimulatorPort
 from webkitpy.port import ios_testcase
+from webkitpy.port import port_testcase
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.mocktool import MockOptions
 from webkitpy.common.system.executive_mock import MockExecutive2, ScriptError
@@ -87,3 +88,19 @@
         port._executive = MockExecutive2(run_command_fn=throwing_run_command)
         expected_stdout = "['xcrun', '--sdk', 'iphonesimulator', '-find', 'test']\n"
         OutputCapture().assert_outputs(self, port.xcrun_find, args=['test', 'falling'], expected_stdout=expected_stdout)
+
+    def test_layout_test_searchpath_with_apple_additions(self):
+        with port_testcase.bind_mock_apple_additions():
+            search_path = self.make_port().default_baseline_search_path()
+        self.assertEqual(search_path[0], '/additional_testing_path/ios-simulator-8-wk1')
+        self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/ios-simulator-8-wk1')
+        self.assertEqual(search_path[2], '/additional_testing_path/ios-simulator-8')
+        self.assertEqual(search_path[3], '/mock-checkout/LayoutTests/platform/ios-simulator-8')
+        self.assertEqual(search_path[4], '/additional_testing_path/ios-simulator-wk1')
+        self.assertEqual(search_path[5], '/mock-checkout/LayoutTests/platform/ios-simulator-wk1')
+        self.assertEqual(search_path[6], '/additional_testing_path/ios-simulator')
+        self.assertEqual(search_path[7], '/mock-checkout/LayoutTests/platform/ios-simulator')
+        self.assertEqual(search_path[8], '/additional_testing_path/ios-8')
+        self.assertEqual(search_path[9], '/mock-checkout/LayoutTests/platform/ios-8')
+        self.assertEqual(search_path[10], '/additional_testing_path/ios-wk1')
+        self.assertEqual(search_path[11], '/mock-checkout/LayoutTests/platform/ios-wk1')

Modified: trunk/Tools/Scripts/webkitpy/port/mac.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/mac.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/mac.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -34,6 +34,7 @@
 
 from webkitpy.common.memoized import memoized
 from webkitpy.common.system.executive import ScriptError
+from webkitpy.port.config import apple_additions
 from webkitpy.port.darwin import DarwinPort
 
 _log = logging.getLogger(__name__)
@@ -56,6 +57,17 @@
     def _build_driver_flags(self):
         return ['ARCHS=i386'] if self.architecture() == 'x86' else []
 
+    def _apple_additions_path(self, name):
+        if name == 'wk2':
+            return None
+        split_name = name.split('-')
+        if len(split_name) > 1 and split_name[1] != 'wk1' and split_name[1] != 'wk2':
+            os_name = apple_additions().mac_os_name(split_name[1])
+            if not os_name:
+                return None
+            name = split_name[0] + '-' + os_name + ('-' + '-'.join(split_name[2:])) if len(split_name) > 2 else ''
+        return self._filesystem.join(apple_additions().layout_tests_path(), name)
+
     @memoized
     def default_baseline_search_path(self):
         wk_string = 'wk1'
@@ -70,7 +82,16 @@
         if self.get_option('webkit_test_runner'):
             fallback_names.append('wk2')
 
-        return map(self._webkit_baseline_path, fallback_names)
+        webkit_expectations = map(self._webkit_baseline_path, fallback_names)
+        if apple_additions() and getattr(apple_additions(), "layout_tests_path", None):
+            apple_expectations = map(self._apple_additions_path, fallback_names)
+            result = []
+            for i in xrange(len(webkit_expectations)):
+                if apple_expectations[i]:
+                    result.append(apple_expectations[i])
+                result.append(webkit_expectations[i])
+            return result
+        return webkit_expectations
 
     def configuration_specifier_macros(self):
         return {

Modified: trunk/Tools/Scripts/webkitpy/port/mac_unittest.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/mac_unittest.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/mac_unittest.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -31,13 +31,11 @@
 
 from webkitpy.port.mac import MacPort
 from webkitpy.port import darwin_testcase
-from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.port import port_testcase
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.tool.mocktool import MockOptions
-from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, MockProcess, ScriptError
-from webkitpy.common.system.systemhost_mock import MockSystemHost
+from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2, ScriptError
 
-
 class MacTest(darwin_testcase.DarwinTest):
     os_name = 'mac'
     os_version = 'lion'
@@ -144,3 +142,9 @@
         port._executive = MockExecutive2(run_command_fn=throwing_run_command)
         expected_stdout = "['xcrun', '--sdk', 'macosx', '-find', 'test']\n"
         OutputCapture().assert_outputs(self, port.xcrun_find, args=['test', 'falling'], expected_stdout=expected_stdout)
+
+    def test_layout_test_searchpath_with_apple_additions(self):
+        with port_testcase.bind_mock_apple_additions():
+            search_path = self.make_port().default_baseline_search_path()
+        self.assertEqual(search_path[0], '/additional_testing_path/mac-lion-wk1')
+        self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/mac-lion-wk1')

Modified: trunk/Tools/Scripts/webkitpy/port/port_testcase.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/port_testcase.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/port_testcase.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -37,11 +37,14 @@
 import time
 import unittest
 
+from contextlib import contextmanager
+
 from webkitpy.common.system.executive_mock import MockExecutive
 from webkitpy.common.system.filesystem_mock import MockFileSystem
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.common.system.systemhost_mock import MockSystemHost
 from webkitpy.port.base import Port
+from webkitpy.port.config import apple_additions
 from webkitpy.port.image_diff import ImageDiffer
 from webkitpy.port.server_process_mock import MockServerProcess
 from webkitpy.layout_tests.servers import http_server_base
@@ -73,6 +76,30 @@
         return ["accessibility", ]
 
 
+@contextmanager
+def bind_mock_apple_additions():
+
+    class MockAppleAdditions(object):
+
+        @staticmethod
+        def layout_tests_path():
+            return '/additional_testing_path/'
+
+        @staticmethod
+        def ios_os_name(name):
+            return name
+
+        @staticmethod
+        def mac_os_name(name):
+            return name
+
+    # apple_additions is a memoized function. Take advantage of this fact and manipulate the cache
+    # to temporarily return a mocked result
+    apple_additions._results_cache[()] = MockAppleAdditions
+    yield
+    apple_additions._results_cache[()] = None
+
+
 class PortTestCase(unittest.TestCase):
     """Tests that all Port implementations must pass."""
     HTTP_PORTS = (8000, 8080, 8443)

Modified: trunk/Tools/Scripts/webkitpy/port/win.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/win.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/win.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -40,8 +40,8 @@
 from webkitpy.common.system.executive import ScriptError, Executive
 from webkitpy.common.system.path import abspath_to_uri, cygpath
 from webkitpy.port.apple import ApplePort
+from webkitpy.port.config import apple_additions
 
-
 _log = logging.getLogger(__name__)
 
 
@@ -113,7 +113,10 @@
             # Note we do not add 'wk2' here, even though it's included in _skipped_search_paths().
         # FIXME: Perhaps we should get this list from MacPort?
         fallback_names.append('mac')
-        return map(self._webkit_baseline_path, fallback_names)
+        result = map(self._webkit_baseline_path, fallback_names)
+        if apple_additions() and getattr(apple_additions(), "layout_tests_path", None):
+            result.insert(0, self._filesystem.join(apple_additions().layout_tests_path(), self.port_name))
+        return result
 
     def setup_environ_for_server(self, server_name=None):
         env = super(WinPort, self).setup_environ_for_server(server_name)

Modified: trunk/Tools/Scripts/webkitpy/port/win_unittest.py (221078 => 221079)


--- trunk/Tools/Scripts/webkitpy/port/win_unittest.py	2017-08-23 16:28:29 UTC (rev 221078)
+++ trunk/Tools/Scripts/webkitpy/port/win_unittest.py	2017-08-23 17:04:25 UTC (rev 221079)
@@ -26,12 +26,7 @@
 # (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 StringIO
-import unittest
-
-from webkitpy.common.system.executive import ScriptError
-from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
-from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.executive_mock import MockExecutive
 from webkitpy.common.system.outputcapture import OutputCapture
 from webkitpy.common.system.systemhost_mock import MockSystemHost
 from webkitpy.port import port_testcase
@@ -116,3 +111,9 @@
         port = self.make_port(port_name='win')
         port._get_crash_log('DumpRenderTree', 1234, '', '', 0,
             time_fn=fake_time_cb(), sleep_fn=lambda delay: None)
+
+    def test_layout_test_searchpath_with_apple_additions(self):
+        with port_testcase.bind_mock_apple_additions():
+            search_path = self.make_port().default_baseline_search_path()
+        self.assertEqual(search_path[0], '/additional_testing_path/win')
+        self.assertEqual(search_path[1], '/mock-checkout/LayoutTests/platform/win-xp')
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to