From 071fe3e521cebb733c4da2ddca576be06a81237e Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 23 Apr 2026 16:49:25 +0700 Subject: [PATCH] fix(ios): propagate error from BootedUDID instead of silently swallowing --- internal/ios/ios.go | 13 ++++++++----- internal/ios/ios_test.go | 5 ++++- internal/testrun/driver.go | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/internal/ios/ios.go b/internal/ios/ios.go index c195b20..fefcb97 100644 --- a/internal/ios/ios.go +++ b/internal/ios/ios.go @@ -55,12 +55,15 @@ func EnsureSimulator(ctx context.Context, deviceName string, stdout io.Writer) e } // BootedUDID returns the UDID of the currently booted iOS simulator, or "" if none is booted. -func BootedUDID(ctx context.Context) string { - d, _ := bootedSimulator(ctx) - if d == nil { - return "" +func BootedUDID(ctx context.Context) (string, error) { + d, err := bootedSimulator(ctx) + if err != nil { + return "", err } - return d.UDID + if d == nil { + return "", nil + } + return d.UDID, nil } func bootedSimulator(ctx context.Context) (*simDevice, error) { diff --git a/internal/ios/ios_test.go b/internal/ios/ios_test.go index d957fe6..cd29f49 100644 --- a/internal/ios/ios_test.go +++ b/internal/ios/ios_test.go @@ -82,7 +82,10 @@ func TestPickSimulator_EmptyList(t *testing.T) { func TestBootedUDID_CanceledContext(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() - udid := BootedUDID(ctx) + udid, err := BootedUDID(ctx) + if err == nil { + t.Error("expected error for canceled context, got nil") + } if udid != "" { t.Errorf("expected empty UDID on canceled context, got %q", udid) } diff --git a/internal/testrun/driver.go b/internal/testrun/driver.go index e7336d3..435fbfe 100644 --- a/internal/testrun/driver.go +++ b/internal/testrun/driver.go @@ -41,7 +41,11 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver "--platform", options.Platform, } if options.Platform == "ios" { - if udid := ios.BootedUDID(ctx); udid != "" { + udid, err := ios.BootedUDID(ctx) + if err != nil { + return nil, nil, fmt.Errorf("find booted simulator: %w", err) + } + if udid != "" { sidecarArgs = append(sidecarArgs, "--udid", udid) } }