From 27e2cbf95653e2658b6c02b39e23eb0ca7bc58e4 Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 9 Jun 2026 18:21:06 +0530 Subject: [PATCH] refactor(ioscompanion): inline single-use devicectl argv builders --- internal/driver/ioscompanion/device.go | 14 ++------------ internal/driver/ioscompanion/device_test.go | 13 ------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/internal/driver/ioscompanion/device.go b/internal/driver/ioscompanion/device.go index 6f474ad..9dd7766 100644 --- a/internal/driver/ioscompanion/device.go +++ b/internal/driver/ioscompanion/device.go @@ -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. diff --git a/internal/driver/ioscompanion/device_test.go b/internal/driver/ioscompanion/device_test.go index 6ad68ce..6865181 100644 --- a/internal/driver/ioscompanion/device_test.go +++ b/internal/driver/ioscompanion/device_test.go @@ -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