webkitpy: Use simctl boot to run multiple simulators at once
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 20:47:44 +0000 (20:47 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 20:47:44 +0000 (20:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172374

Reviewed by Alexey Proskuryakov.

* Scripts/webkitpy/common/system/platforminfo.py:
(PlatformInfo.xcode_version): Return the current version of Xcode.
* Scripts/webkitpy/common/system/platforminfo_mock.py:
(MockPlatformInfo.xcode_version): Return version 8.0 for testing.
* Scripts/webkitpy/port/ios_simulator.py:
(IOSSimulatorPort.use_multiple_simulator_apps): Return true if we need to
run multiple Simulator.app instances.
(IOSSimulatorPort._create_simulators): Only copy the simulator app for older
versions of Xcode.
(IOSSimulatorPort._create_devices): Use 'simctl boot' directly unless using
an older version of Xcode.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/platforminfo.py
Tools/Scripts/webkitpy/common/system/platforminfo_mock.py
Tools/Scripts/webkitpy/port/ios_simulator.py

index 90cc85a..a31affa 100644 (file)
@@ -1,3 +1,22 @@
+2017-05-19  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Use simctl boot to run multiple simulators at once
+        https://bugs.webkit.org/show_bug.cgi?id=172374
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Scripts/webkitpy/common/system/platforminfo.py:
+        (PlatformInfo.xcode_version): Return the current version of Xcode.
+        * Scripts/webkitpy/common/system/platforminfo_mock.py:
+        (MockPlatformInfo.xcode_version): Return version 8.0 for testing.
+        * Scripts/webkitpy/port/ios_simulator.py:
+        (IOSSimulatorPort.use_multiple_simulator_apps): Return true if we need to
+        run multiple Simulator.app instances.
+        (IOSSimulatorPort._create_simulators): Only copy the simulator app for older
+        versions of Xcode.
+        (IOSSimulatorPort._create_devices): Use 'simctl boot' directly unless using
+        an older version of Xcode.
+
 2017-05-19  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Unreviewed, fix the build on the latest internal SDK.
index 6f96829..ec8c219 100644 (file)
@@ -133,6 +133,11 @@ class PlatformInfo(object):
         output = self._executive.run_command(['xcrun', 'simctl', 'list'], return_stderr=False)
         return (line for line in output.splitlines())
 
+    def xcode_version(self):
+        if not self.is_mac():
+            raise NotImplementedError
+        return self._executive.run_command(['xcodebuild', '-version']).split()[1]
+
     def _determine_os_name(self, sys_platform):
         if sys_platform == 'darwin':
             return 'mac'
index 14fe3cd..859d3a6 100644 (file)
@@ -60,5 +60,8 @@ class MockPlatformInfo(object):
     def xcode_sdk_version(self, sdk_name):
         return '8.1'
 
+    def xcode_version(self):
+        return '8.0'
+
     def xcode_simctl_list(self):
         return self.expected_xcode_simctl_list
index e449f82..80a4348 100644 (file)
@@ -170,6 +170,9 @@ class IOSSimulatorPort(IOSPort):
             except:
                 _log.warning('Unable to remove Simulator' + str(i))
 
+    def use_multiple_simulator_apps(self):
+        return int(self.host.platform.xcode_version().split('.')[0]) < 9
+
     def _create_simulators(self):
         if (self.default_child_processes() < self.child_processes()):
             _log.warn('You have specified very high value({0}) for --child-processes'.format(self.child_processes()))
@@ -178,7 +181,9 @@ class IOSSimulatorPort(IOSPort):
 
         if self._using_dedicated_simulators():
             atexit.register(lambda: self._teardown_managed_simulators())
-            self._createSimulatorApps()
+
+            if self.use_multiple_simulator_apps():
+                self._createSimulatorApps()
 
             for i in xrange(self.child_processes()):
                 self._create_device(i)
@@ -211,16 +216,23 @@ class IOSSimulatorPort(IOSPort):
             _log.debug('testing device %s has udid %s', i, device_udid)
 
             # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator
-            self._executive.run_command([
-                'open', '-g', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
-                '--args', '-CurrentDeviceUDID', device_udid])
+            if self.use_multiple_simulator_apps():
+                self._executive.run_command([
+                    'open', '-g', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
+                    '--args', '-CurrentDeviceUDID', device_udid])
+            else:
+                self._executive.run_command(['xcrun', 'simctl', 'boot', device_udid])
 
             if mac_os_version in ['elcapitan', 'yosemite', 'mavericks']:
                 time.sleep(2.5)
 
+        if not self.use_multiple_simulator_apps():
+            self._executive.run_command(['open', '-g', '-b', self.SIMULATOR_BUNDLE_ID])
+
         _log.info('Waiting for all iOS Simulators to finish booting.')
         for i in xrange(self.child_processes()):
             Simulator.wait_until_device_is_booted(Simulator.managed_devices[i].udid)
+        _log.info('All simulators have booted.')
 
         IOSSimulatorPort._DEVICE_MAP = {}
         for i in xrange(self.child_processes()):