mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
refactor(ioscompanion): inline single-use devicectl argv builders
This commit is contained in:
1 parent
82dc7566a1
commit
27e2cbf956
2 files changed
+2
-25
No files matched your search
@@ -199,24 +199,14 @@ func (d *Driver) respawnDevice(ctx context.Context) error {
|
||||
// keyed on the CoreDevice id. App lifecycle stays with devicectl: the runner's
|
||||
// own install path is simulator-specific.
|
||||
func (d *Driver) devicectlReinstall(ctx context.Context) error {
|
||||
_ = exec.CommandContext(ctx, "xcrun", devicectlUninstallArgs(d.coreDeviceID, d.bundleID)...).Run()
|
||||
output, err := exec.CommandContext(ctx, "xcrun", devicectlInstallArgs(d.coreDeviceID, d.appPath)...).CombinedOutput()
|
||||
_ = exec.CommandContext(ctx, "xcrun", "devicectl", "device", "uninstall", "app", "--device", d.coreDeviceID, d.bundleID).Run()
|
||||
output, err := exec.CommandContext(ctx, "xcrun", "devicectl", "device", "install", "app", "--device", d.coreDeviceID, d.appPath).CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("devicectl install: %w: %s", err, strings.TrimSpace(string(output)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// devicectlUninstallArgs and devicectlInstallArgs build the devicectl app
|
||||
// lifecycle commands keyed on the CoreDevice id, as xcrun subcommand arguments.
|
||||
func devicectlUninstallArgs(coreDeviceID, bundleID string) []string {
|
||||
return []string{"devicectl", "device", "uninstall", "app", "--device", coreDeviceID, bundleID}
|
||||
}
|
||||
|
||||
func devicectlInstallArgs(coreDeviceID, appPath string) []string {
|
||||
return []string{"devicectl", "device", "install", "app", "--device", coreDeviceID, appPath}
|
||||
}
|
||||
|
||||
// deviceResetContainerUnsupported warns once that device clear-state needs an
|
||||
// app path for a devicectl reinstall: there is no simulator-style data-container
|
||||
// wipe on a physical device.
|
||||
|
||||
@@ -196,19 +196,6 @@ func TestDeviceCloseStopsRunnerAndTunnel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDevicectlReinstallArgs(t *testing.T) {
|
||||
uninstall := devicectlUninstallArgs("CORE-1", "com.example.app")
|
||||
wantUninstall := []string{"devicectl", "device", "uninstall", "app", "--device", "CORE-1", "com.example.app"}
|
||||
if !equalArgs(uninstall, wantUninstall) {
|
||||
t.Fatalf("uninstall args = %v, want %v", uninstall, wantUninstall)
|
||||
}
|
||||
install := devicectlInstallArgs("CORE-1", "/tmp/app.app")
|
||||
wantInstall := []string{"devicectl", "device", "install", "app", "--device", "CORE-1", "/tmp/app.app"}
|
||||
if !equalArgs(install, wantInstall) {
|
||||
t.Fatalf("install args = %v, want %v", install, wantInstall)
|
||||
}
|
||||
}
|
||||
|
||||
func equalArgs(got, want []string) bool {
|
||||
if len(got) != len(want) {
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user