webkitpy: Retry app installation on watchOS simulators
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Nov 2018 00:02:14 +0000 (00:02 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Nov 2018 00:02:14 +0000 (00:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191769
<rdar://problem/46139850>

Reviewed by Aakash Jain.

* Scripts/webkitpy/xcode/simulated_device.py:
(SimulatedDevice.install_app): Retry app installations.

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

Tools/ChangeLog
Tools/Scripts/webkitpy/xcode/simulated_device.py

index ca8649a..0afb06a 100644 (file)
@@ -1,3 +1,14 @@
+2018-11-16  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Retry app installation on watchOS simulators
+        https://bugs.webkit.org/show_bug.cgi?id=191769
+        <rdar://problem/46139850>
+
+        Reviewed by Aakash Jain.
+
+        * Scripts/webkitpy/xcode/simulated_device.py:
+        (SimulatedDevice.install_app): Retry app installations.
+
 2018-11-16  Zalan Bujtas  <zalan@apple.com>
 
         Add DidFirstMeaningfulPaint milestone.
index 6ff31a8..62f20e8 100644 (file)
@@ -454,6 +454,7 @@ class SimulatedDevice(object):
         BOOTED = 3
         SHUTTING_DOWN = 4
 
+    NUM_INSTALL_RETRIES = 3
     NAME_FOR_STATE = [
         'CREATING',
         'SHUTDOWN',
@@ -544,7 +545,18 @@ class SimulatedDevice(object):
                 SimulatedDeviceManager.INITIALIZED_DEVICES.remove(device)
 
     def install_app(self, app_path, env=None):
-        return not self.executive.run_command(['xcrun', 'simctl', 'install', self.udid, app_path], return_exit_code=True)
+        # Even after carousel is running, it takes a few seconds for watchOS to allow installs.
+        for i in xrange(self.NUM_INSTALL_RETRIES):
+            exit_code = self.executive.run_command(['xcrun', 'simctl', 'install', self.udid, app_path], return_exit_code=True)
+            if exit_code == 0:
+                return True
+
+            # Return code 204 indicates that the device is booting, a retry may be successful.
+            if exit_code == 204:
+                time.sleep(5)
+                continue
+            return False
+        return False
 
     # FIXME: Increase timeout for <rdar://problem/31331576>
     def launch_app(self, bundle_id, args, env=None, timeout=300):