diff options
author | Elias Naur <elias.naur@gmail.com> | 2018-05-02 23:26:58 +0200 |
---|---|---|
committer | Elias Naur <elias.naur@gmail.com> | 2018-05-03 07:45:46 +0000 |
commit | 78cb5d7a68f994978b1520baf724c8a7008a97c0 (patch) | |
tree | 3c3bd302e9c885730db0d15d2e9bc2906fc8ea5d /misc/ios | |
parent | 7b451dc715a728ea03edf17fa497d8f72d32a03f (diff) | |
download | go-78cb5d7a68f994978b1520baf724c8a7008a97c0.tar.gz go-78cb5d7a68f994978b1520baf724c8a7008a97c0.zip |
misc/ios: retry app install
Sometimes ideviceinstaller fails to install the app. Retry a few
times before giving up.
For the iOS builder.
Change-Id: Ib066ffd4f97ae8d22c0fa9a78ea4d04f67c17410
Reviewed-on: https://go-review.googlesource.com/111055
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'misc/ios')
-rw-r--r-- | misc/ios/go_darwin_arm_exec.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/misc/ios/go_darwin_arm_exec.go b/misc/ios/go_darwin_arm_exec.go index 6c5a913bc6..985c82bf81 100644 --- a/misc/ios/go_darwin_arm_exec.go +++ b/misc/ios/go_darwin_arm_exec.go @@ -377,15 +377,25 @@ func findDeviceAppPath(bundleID string) (string, error) { } func install(appdir string) error { - cmd := idevCmd(exec.Command( - "ideviceinstaller", - "-i", appdir, - )) - if out, err := cmd.CombinedOutput(); err != nil { - os.Stderr.Write(out) - return fmt.Errorf("ideviceinstaller -i %q: %v", appdir, err) + attempt := 0 + for { + cmd := idevCmd(exec.Command( + "ideviceinstaller", + "-i", appdir, + )) + if out, err := cmd.CombinedOutput(); err != nil { + // Sometimes, installing the app fails for some reason. + // Give the device a few seconds and try again. + if attempt < 5 { + time.Sleep(5 * time.Second) + attempt++ + continue + } + os.Stderr.Write(out) + return fmt.Errorf("ideviceinstaller -i %q: %v (%d attempts)", appdir, err, attempt) + } + return nil } - return nil } func idevCmd(cmd *exec.Cmd) *exec.Cmd { |