Commit 9b16b9c7 authored by Elias Naur's avatar Elias Naur

misc/ios: uninstall app before installing it

Tests can fail because there is leftover data from a previous run.
For example:

--- FAIL: TestRemoveAll (0.00s)
	path_test.go:96: RemoveAll "/private/var/mobile/Containers/Data/Application/66247524-5ED7-45A4-82AA-6BF15D6078B2/tmp//_TestRemoveAll_" (first): open /private/var/mobile/Containers/Data/Application/66247524-5ED7-45A4-82AA-6BF15D6078B2/tmp//_TestRemoveAll_/dir: permission denied
FAIL
FAIL	os	31.275s

There seem to be no way to simply clear the app data for an app
short of uninstalling it, so do that.

This change in effect undoes CL 106676, which means that running iOS
is a little slower again, and that another app from the same
apple developer account must be present on the device for our app
install to succeed.

Change-Id: Iacc3a6f95c93568f4418db45e1098c7c7fdb88e0
Reviewed-on: https://go-review.googlesource.com/111795
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a33c5957
...@@ -125,6 +125,10 @@ func runMain() (int, error) { ...@@ -125,6 +125,10 @@ func runMain() (int, error) {
return 1, err return 1, err
} }
if err := uninstall(bundleID); err != nil {
return 1, err
}
if err := install(appdir); err != nil { if err := install(appdir); err != nil {
return 1, err return 1, err
} }
...@@ -413,6 +417,18 @@ func parsePlistDict(dict []byte) (map[string]string, error) { ...@@ -413,6 +417,18 @@ func parsePlistDict(dict []byte) (map[string]string, error) {
return values, nil return values, nil
} }
func uninstall(bundleID string) error {
cmd := idevCmd(exec.Command(
"ideviceinstaller",
"-U", bundleID,
))
if out, err := cmd.CombinedOutput(); err != nil {
os.Stderr.Write(out)
return fmt.Errorf("ideviceinstaller -U %q: %s", bundleID, err)
}
return nil
}
func install(appdir string) error { func install(appdir string) error {
attempt := 0 attempt := 0
for { for {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment