webkitpy: Unify ios_version/watchos_version code
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 18:00:14 +0000 (18:00 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 18:00:14 +0000 (18:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192153
<rdar://problem/46343642>

Reviewed by Lucas Forschler.

Treating watchOS and iOS versions differently makes it harder to share code between the similar ports.

* Scripts/webkitpy/port/device_port.py:
(DevicePort):
(DevicePort.device_version): Added.
* Scripts/webkitpy/port/ios.py:
(IOSPort.default_baseline_search_path): Use device_version() instead of ios_version().
(IOSPort.ios_version): Deleted.
* Scripts/webkitpy/port/ios_device.py:
(IOSDevicePort.device_version): Renamed from ios_version().
(IOSDevicePort.ios_version): Deleted.
* Scripts/webkitpy/port/ios_simulator.py:
(IOSSimulatorPort.device_version): Renamed from ios_version().
(IOSSimulatorPort.default_child_processes.booted_ios_devices_filter): Use device_version() instead of ios_version().
(IOSSimulatorPort._create_devices): Ditto.
(IOSSimulatorPort.check_sys_deps): Ditto.
(IOSSimulatorPort.ios_version): Deleted.
* Scripts/webkitpy/port/watch.py:
(WatchPort.default_baseline_search_path): Use device_version() instead of watchos_version().
(WatchPort.watchos_version): Deleted.
* Scripts/webkitpy/port/watch_device.py:
(WatchDevicePort.device_version): Renamed from watchos_version().
(WatchDevicePort.watchos_version): Deleted.
* Scripts/webkitpy/port/watch_simulator.py:
(WatchSimulatorPort.device_version): Renamed from watchos_version().
(WatchSimulatorPort.default_child_processes.filter_booted_watchos_devices): Use device_version() instead of watchos_version().
(WatchSimulatorPort._create_devices): Ditto.
(WatchSimulatorPort.check_sys_deps): Ditto.
(WatchSimulatorPort.watchos_version): Deleted.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/port/device_port.py
Tools/Scripts/webkitpy/port/ios.py
Tools/Scripts/webkitpy/port/ios_device.py
Tools/Scripts/webkitpy/port/ios_simulator.py
Tools/Scripts/webkitpy/port/watch.py
Tools/Scripts/webkitpy/port/watch_device.py
Tools/Scripts/webkitpy/port/watch_simulator.py

index 67489f2..7a7a9d0 100644 (file)
@@ -1,3 +1,41 @@
+2018-11-29  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Unify ios_version/watchos_version code
+        https://bugs.webkit.org/show_bug.cgi?id=192153
+        <rdar://problem/46343642>
+
+        Reviewed by Lucas Forschler.
+
+        Treating watchOS and iOS versions differently makes it harder to share code between the similar ports.
+
+        * Scripts/webkitpy/port/device_port.py:
+        (DevicePort):
+        (DevicePort.device_version): Added.
+        * Scripts/webkitpy/port/ios.py:
+        (IOSPort.default_baseline_search_path): Use device_version() instead of ios_version().
+        (IOSPort.ios_version): Deleted.
+        * Scripts/webkitpy/port/ios_device.py:
+        (IOSDevicePort.device_version): Renamed from ios_version().
+        (IOSDevicePort.ios_version): Deleted.
+        * Scripts/webkitpy/port/ios_simulator.py:
+        (IOSSimulatorPort.device_version): Renamed from ios_version().
+        (IOSSimulatorPort.default_child_processes.booted_ios_devices_filter): Use device_version() instead of ios_version().
+        (IOSSimulatorPort._create_devices): Ditto.
+        (IOSSimulatorPort.check_sys_deps): Ditto.
+        (IOSSimulatorPort.ios_version): Deleted.
+        * Scripts/webkitpy/port/watch.py:
+        (WatchPort.default_baseline_search_path): Use device_version() instead of watchos_version().
+        (WatchPort.watchos_version): Deleted.
+        * Scripts/webkitpy/port/watch_device.py:
+        (WatchDevicePort.device_version): Renamed from watchos_version().
+        (WatchDevicePort.watchos_version): Deleted.
+        * Scripts/webkitpy/port/watch_simulator.py:
+        (WatchSimulatorPort.device_version): Renamed from watchos_version().
+        (WatchSimulatorPort.default_child_processes.filter_booted_watchos_devices): Use device_version() instead of watchos_version().
+        (WatchSimulatorPort._create_devices): Ditto.
+        (WatchSimulatorPort.check_sys_deps): Ditto.
+        (WatchSimulatorPort.watchos_version): Deleted.
+
 2018-11-28  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOSMac] Dropping text selections from web content into editable elements crashes the web process
index a2b2076..9422e8c 100644 (file)
@@ -160,3 +160,6 @@ class DevicePort(DarwinPort):
             self._append_value_colon_separated(env, '__XPC_DYLD_INSERT_LIBRARIES', '/usr/lib/libgmalloc.dylib')
         env['XML_CATALOG_FILES'] = ''  # work around missing /etc/catalog <rdar://problem/4292995>
         return env
+
+    def device_version(self):
+        raise NotImplementedError
index 19a5e6a..6e66ff6 100644 (file)
@@ -56,10 +56,10 @@ class IOSPort(DevicePort):
             wk_string = 'wk2'
 
         versions_to_fallback = []
-        if self.ios_version().major == self.CURRENT_VERSION.major:
+        if self.device_version().major == self.CURRENT_VERSION.major:
             versions_to_fallback = [self.CURRENT_VERSION]
-        elif self.ios_version():
-            temp_version = Version(self.ios_version().major)
+        elif self.device_version():
+            temp_version = Version(self.device_version().major)
             while temp_version != self.CURRENT_VERSION:
                 versions_to_fallback.append(Version.from_iterable(temp_version))
                 if temp_version < self.CURRENT_VERSION:
@@ -109,6 +109,3 @@ class IOSPort(DevicePort):
 
     def test_expectations_file_position(self):
         return 4
-
-    def ios_version(self):
-        raise NotImplementedError
index 641215a..8580d0b 100644 (file)
@@ -87,7 +87,7 @@ class IOSDevicePort(IOSPort):
         return (stderr, None)
 
     @memoized
-    def ios_version(self):
+    def device_version(self):
         if self.get_option('version'):
             return Version.from_string(self.get_option('version'))
 
index e8f63fe..04230dc 100644 (file)
@@ -60,7 +60,7 @@ class IOSSimulatorPort(IOSPort):
         return None
 
     @memoized
-    def ios_version(self):
+    def device_version(self):
         if self.get_option('version'):
             return Version.from_string(self.get_option('version'))
         return IOSSimulatorPort._version_from_name(self._name) if IOSSimulatorPort._version_from_name(self._name) else self.host.platform.xcode_sdk_version('iphonesimulator')
@@ -70,8 +70,7 @@ class IOSSimulatorPort(IOSPort):
         def booted_ios_devices_filter(device):
             if not device.platform_device.is_booted_or_booting():
                 return False
-            return device.platform_device.device_type in DeviceType(software_variant='iOS',
-                                                                    software_version=self.ios_version())
+            return device.platform_device.device_type in DeviceType(software_variant='iOS', software_version=self.device_version())
 
         if not self.get_option('dedicated_simulators', False):
             num_booted_sims = len(SimulatedDeviceManager.device_by_filter(booted_ios_devices_filter, host=self.host))
@@ -84,7 +83,7 @@ class IOSSimulatorPort(IOSPort):
 
     def _create_devices(self, device_class):
         self._set_device_class(device_class)
-        device_type = DeviceType.from_string(self._device_class, self.ios_version())
+        device_type = DeviceType.from_string(self._device_class, self.device_version())
 
         _log.debug('\nCreating devices for {}'.format(device_type))
 
@@ -128,7 +127,7 @@ class IOSSimulatorPort(IOSPort):
         return 'ios-simulator'
 
     def check_sys_deps(self):
-        target_device_type = DeviceType(software_variant='iOS', software_version=self.ios_version())
+        target_device_type = DeviceType(software_variant='iOS', software_version=self.device_version())
         for device in SimulatedDeviceManager.available_devices(self.host):
             if device.platform_device.device_type in target_device_type:
                 return super(IOSSimulatorPort, self).check_sys_deps()
index cfbe875..cc3085b 100644 (file)
@@ -59,10 +59,10 @@ class WatchPort(DevicePort):
     @memoized
     def default_baseline_search_path(self):
         versions_to_fallback = []
-        if self.watchos_version() == self.CURRENT_VERSION:
+        if self.device_version() == self.CURRENT_VERSION:
             versions_to_fallback = [self.CURRENT_VERSION]
-        elif self.watchos_version():
-            temp_version = Version(self.watchos_version().major)
+        elif self.device_version():
+            temp_version = Version(self.device_version().major)
             while temp_version.major != self.CURRENT_VERSION.major:
                 versions_to_fallback.append(Version.from_iterable(temp_version))
                 if temp_version < self.CURRENT_VERSION:
@@ -97,7 +97,3 @@ class WatchPort(DevicePort):
         expectations.append(self._webkit_baseline_path('wk2'))
 
         return expectations
-
-    def watchos_version(self):
-        # The implementation of this function differs between on-device and simulator testing.
-        raise NotImplementedError
index 1d20230..3781f59 100644 (file)
@@ -85,7 +85,7 @@ class WatchDevicePort(WatchPort):
         return (stderr, None)
 
     @memoized
-    def watchos_version(self):
+    def device_version(self):
         if self.get_option('version'):
             return Version.from_string(self.get_option('version'))
 
index 82f1389..c1c5934 100644 (file)
@@ -62,7 +62,7 @@ class WatchSimulatorPort(WatchPort):
         return None
 
     @memoized
-    def watchos_version(self):
+    def device_version(self):
         if self.get_option('version'):
             return Version.from_string(self.get_option('version'))
         return WatchSimulatorPort._version_from_name(self._name) or self.host.platform.xcode_sdk_version('watchsimulator')
@@ -83,7 +83,7 @@ class WatchSimulatorPort(WatchPort):
         def filter_booted_watchos_devices(device):
             if not device.platform_device.is_booted_or_booting():
                 return False
-            return device.platform_device.device_type in DeviceType(software_variant='watchOS', software_version=self.watchos_version())
+            return device.platform_device.device_type in DeviceType(software_variant='watchOS', software_version=self.device_version())
 
         if not self.get_option('dedicated_simulators', False):
             num_booted_sims = len(SimulatedDeviceManager.device_by_filter(filter_booted_watchos_devices, host=self.host))
@@ -96,7 +96,7 @@ class WatchSimulatorPort(WatchPort):
 
     def _create_devices(self, device_class):
         self._set_device_class(device_class)
-        device_type = DeviceType.from_string(self._device_class, self.watchos_version())
+        device_type = DeviceType.from_string(self._device_class, self.device_version())
 
         _log.debug('\nCreating devices for {}'.format(device_type))
 
@@ -112,7 +112,7 @@ class WatchSimulatorPort(WatchPort):
         return 'watchos-simulator'
 
     def check_sys_deps(self):
-        target_device_type = DeviceType(software_variant='watchOS', software_version=self.watchos_version())
+        target_device_type = DeviceType(software_variant='watchOS', software_version=self.device_version())
         for device in SimulatedDeviceManager.available_devices(self.host):
             if device.platform_device.device_type in target_device_type:
                 return super(WatchSimulatorPort, self).check_sys_deps()