Title: [238694] trunk/Tools
Revision
238694
Author
jbed...@apple.com
Date
2018-11-29 13:58:30 -0800 (Thu, 29 Nov 2018)

Log Message

webkitpy: Unify device creation
https://bugs.webkit.org/show_bug.cgi?id=192158
<rdar://problem/46344757>

Reviewed by Lucas Forschler.

* Scripts/webkitpy/port/device_port.py:
(DevicePort):
(DevicePort.setup_test_run): Use DEVICE_MANAGER to create devices based on the specified device class.
* Scripts/webkitpy/port/ios.py:
(IOSPort): Add DEFAULT_DEVICE_CLASS.
* Scripts/webkitpy/port/ios_device.py:
(IOSDevicePort):
(IOSDevicePort._create_devices): Deleted.
* Scripts/webkitpy/port/ios_simulator.py:
(IOSSimulatorPort._create_devices): Deleted.
* Scripts/webkitpy/port/watch.py:
(WatchPort): Add DEFAULT_DEVICE_CLASS.
* Scripts/webkitpy/port/watch_device.py:
(WatchDevicePort):
(WatchDevicePort._create_devices): Deleted.
* Scripts/webkitpy/port/watch_simulator.py:
(WatchSimulatorPort._create_devices): Deleted.
* Scripts/webkitpy/xcode/device_type_unittest.py:
(DeviceTypeTest.test_from_string): Test that DeviceTypes without hardware types can be constructed
from strings.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (238693 => 238694)


--- trunk/Tools/ChangeLog	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/ChangeLog	2018-11-29 21:58:30 UTC (rev 238694)
@@ -1,5 +1,34 @@
 2018-11-29  Jonathan Bedard  <jbed...@apple.com>
 
+        webkitpy: Unify device creation
+        https://bugs.webkit.org/show_bug.cgi?id=192158
+        <rdar://problem/46344757>
+
+        Reviewed by Lucas Forschler.
+
+        * Scripts/webkitpy/port/device_port.py:
+        (DevicePort):
+        (DevicePort.setup_test_run): Use DEVICE_MANAGER to create devices based on the specified device class.
+        * Scripts/webkitpy/port/ios.py:
+        (IOSPort): Add DEFAULT_DEVICE_CLASS.
+        * Scripts/webkitpy/port/ios_device.py:
+        (IOSDevicePort):
+        (IOSDevicePort._create_devices): Deleted.
+        * Scripts/webkitpy/port/ios_simulator.py:
+        (IOSSimulatorPort._create_devices): Deleted.
+        * Scripts/webkitpy/port/watch.py:
+        (WatchPort): Add DEFAULT_DEVICE_CLASS.
+        * Scripts/webkitpy/port/watch_device.py:
+        (WatchDevicePort):
+        (WatchDevicePort._create_devices): Deleted.
+        * Scripts/webkitpy/port/watch_simulator.py:
+        (WatchSimulatorPort._create_devices): Deleted.
+        * Scripts/webkitpy/xcode/device_type_unittest.py:
+        (DeviceTypeTest.test_from_string): Test that DeviceTypes without hardware types can be constructed
+        from strings.
+
+2018-11-29  Jonathan Bedard  <jbed...@apple.com>
+
         EWS iOS-sim bots sometimes fails to shutdown simulator
         https://bugs.webkit.org/show_bug.cgi?id=191864
 

Modified: trunk/Tools/Scripts/webkitpy/port/device_port.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/device_port.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/device_port.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -27,6 +27,8 @@
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
 from webkitpy.port.darwin import DarwinPort
 from webkitpy.port.simulator_process import SimulatorProcess
+from webkitpy.xcode.device_type import DeviceType
+from webkitpy.xcode.simulated_device import DeviceRequest
 
 
 _log = logging.getLogger(__name__)
@@ -35,6 +37,8 @@
 class DevicePort(DarwinPort):
 
     DEVICE_MANAGER = None
+    DEFAULT_DEVICE_CLASS = None
+    NO_DEVICE_MANAGER = 'No device manager found for port'
 
     def __init__(self, *args, **kwargs):
         super(DevicePort, self).__init__(*args, **kwargs)
@@ -106,7 +110,25 @@
                 raise RuntimeError('Failed to install dylibs at {} on device {}'.format(self._build_path(), device.udid))
 
     def setup_test_run(self, device_class=None):
-        self._create_devices(device_class)
+        if not self.DEVICE_MANAGER:
+            raise RuntimeError(self.NO_DEVICE_MANAGER)
+
+        device_type = DeviceType.from_string(device_class if device_class else self.DEFAULT_DEVICE_CLASS, self.device_version())
+        _log.debug('\nCreating devices for {}'.format(device_type))
+
+        request = DeviceRequest(
+            device_type,
+            use_booted_simulator=not self.get_option('dedicated_simulators', False),
+            use_existing_simulator=False,
+            allow_incomplete_match=True,
+        )
+        self.DEVICE_MANAGER.initialize_devices([request] * self.child_processes(), self.host)
+
+        if not self.devices():
+            raise RuntimeError('No devices are available for testing')
+        if self.default_child_processes() < self.child_processes():
+            raise RuntimeError('To few connected devices for {} processes'.format(self.child_processes()))
+
         self._install()
 
         for i in xrange(self.child_processes()):

Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/ios.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -38,6 +38,8 @@
     port_name = "ios"
 
     CURRENT_VERSION = Version(12)
+    # FIXME: This is not a clear way to do this (although it works) https://bugs.webkit.org/show_bug.cgi?id=192160
+    DEFAULT_DEVICE_CLASS = ''
 
     def __init__(self, host, port_name, **kwargs):
         super(IOSPort, self).__init__(host, port_name, **kwargs)

Modified: trunk/Tools/Scripts/webkitpy/port/ios_device.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/ios_device.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/ios_device.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -41,7 +41,8 @@
     DEVICE_MANAGER = apple_additions().device_manager() if apple_additions() else None
 
     SDK = apple_additions().get_sdk('iphoneos') if apple_additions() else 'iphoneos'
-    NO_ON_DEVICE_TESTING = 'On-device testing is not supported on this machine'
+    NO_ON_DEVICE_TESTING = 'On-device testing is not supported in this configuration'
+    NO_DEVICE_MANAGER = NO_ON_DEVICE_TESTING
 
     @memoized
     def default_child_processes(self):
@@ -112,15 +113,6 @@
     def operating_system(self):
         return 'ios-device'
 
-    def _create_devices(self, device_class):
-        if not apple_additions():
-            raise RuntimeError(self.NO_ON_DEVICE_TESTING)
-        if not self.devices():
-            raise RuntimeError('No devices are available for testing')
-
-        if self.default_child_processes() < self.child_processes():
-            raise RuntimeError('Not enought connected devices for {} processes'.format(self.child_processes()))
-
     def clean_up_test_run(self):
         super(IOSDevicePort, self).clean_up_test_run()
         apple_additions().ios_device_clean_up_test_run(self, self._path_to_driver(), self._build_path())

Modified: trunk/Tools/Scripts/webkitpy/port/ios_simulator.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/ios_simulator.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/ios_simulator.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -27,7 +27,7 @@
 from webkitpy.port.config import apple_additions
 from webkitpy.port.ios import IOSPort
 from webkitpy.xcode.device_type import DeviceType
-from webkitpy.xcode.simulated_device import DeviceRequest, SimulatedDeviceManager
+from webkitpy.xcode.simulated_device import SimulatedDeviceManager
 
 
 _log = logging.getLogger(__name__)
@@ -81,20 +81,6 @@
     def _set_device_class(self, device_class):
         self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
 
-    def _create_devices(self, device_class):
-        self._set_device_class(device_class)
-        device_type = DeviceType.from_string(self._device_class, self.device_version())
-
-        _log.debug('\nCreating devices for {}'.format(device_type))
-
-        request = DeviceRequest(
-            device_type,
-            use_booted_simulator=not self.get_option('dedicated_simulators', False),
-            use_existing_simulator=False,
-            allow_incomplete_match=True,
-        )
-        SimulatedDeviceManager.initialize_devices([request] * self.child_processes(), self.host)
-
     def clean_up_test_run(self):
         super(IOSSimulatorPort, self).clean_up_test_run()
         _log.debug("clean_up_test_run")

Modified: trunk/Tools/Scripts/webkitpy/port/watch.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/watch.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/watch.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -36,6 +36,7 @@
     port_name = 'watchos'
 
     CURRENT_VERSION = Version(5)
+    DEFAULT_DEVICE_CLASS = 'Apple Watch'
 
     def __init__(self, *args, **kwargs):
         super(WatchPort, self).__init__(*args, **kwargs)

Modified: trunk/Tools/Scripts/webkitpy/port/watch_device.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/watch_device.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/watch_device.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -40,6 +40,7 @@
     SDK = apple_additions().get_sdk('watchos') if apple_additions() else 'watchos'
     DEVICE_MANAGER = apple_additions().device_manager() if apple_additions() else None
     NO_ON_DEVICE_TESTING = 'On-device testing is not supported in this configuration'
+    NO_DEVICE_MANAGER = NO_ON_DEVICE_TESTING
 
     @memoized
     def default_child_processes(self):
@@ -110,15 +111,6 @@
     def operating_system(self):
         return 'watchos-device'
 
-    def _create_devices(self, device_class):
-        if not apple_additions():
-            raise RuntimeError(self.NO_ON_DEVICE_TESTING)
-        if not apple_additions().device_for_worker_number_map(self, software_variant='watchOS'):
-            raise RuntimeError('No devices are available for testing')
-
-        if self.default_child_processes() < self.child_processes():
-            raise RuntimeError('Not enought connected devices for {} processes'.format(self.child_processes()))
-
     def clean_up_test_run(self):
         super(WatchDevicePort, self).clean_up_test_run()
         apple_additions().device_clean_up_test_run(self, self._path_to_driver(), self._build_path())

Modified: trunk/Tools/Scripts/webkitpy/port/watch_simulator.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/port/watch_simulator.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/port/watch_simulator.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -27,7 +27,7 @@
 from webkitpy.port.config import apple_additions
 from webkitpy.port.watch import WatchPort
 from webkitpy.xcode.device_type import DeviceType
-from webkitpy.xcode.simulated_device import DeviceRequest, SimulatedDeviceManager
+from webkitpy.xcode.simulated_device import SimulatedDeviceManager
 
 _log = logging.getLogger(__name__)
 
@@ -94,20 +94,6 @@
     def _set_device_class(self, device_class):
         self._device_class = device_class or self.DEFAULT_DEVICE_CLASS
 
-    def _create_devices(self, device_class):
-        self._set_device_class(device_class)
-        device_type = DeviceType.from_string(self._device_class, self.device_version())
-
-        _log.debug('\nCreating devices for {}'.format(device_type))
-
-        request = DeviceRequest(
-            device_type,
-            use_booted_simulator=not self.get_option('dedicated_simulators', False),
-            use_existing_simulator=False,
-            allow_incomplete_match=True,
-        )
-        SimulatedDeviceManager.initialize_devices([request] * self.child_processes(), self.host)
-
     def operating_system(self):
         return 'watchos-simulator'
 

Modified: trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py (238693 => 238694)


--- trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py	2018-11-29 21:50:43 UTC (rev 238693)
+++ trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py	2018-11-29 21:58:30 UTC (rev 238694)
@@ -103,6 +103,8 @@
         self.assertEqual('iPad Air 2 running iOS', str(DeviceType.from_string('iPad Air 2')))
         self.assertEqual('Apple Watch Series 2 - 42mm running watchOS', str(DeviceType.from_string('Apple Watch Series 2 - 42mm')))
         self.assertEqual('Apple TV 4K running tvOS', str(DeviceType.from_string('Apple TV 4K')))
+        self.assertEqual('Device running iOS', str(DeviceType.from_string('')))
+        self.assertEqual('Apple Watch running watchOS', str(DeviceType.from_string('Apple Watch')))
 
     def test_comparison(self):
         # iPhone comparisons
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to