mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(ios): propagate error from BootedUDID instead of silently swallowing
This commit is contained in:
1 parent
55ad503856
commit
071fe3e521
3 files changed
+17
-7
No files matched your search
+8
-5
@@ -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.
|
// BootedUDID returns the UDID of the currently booted iOS simulator, or "" if none is booted.
|
||||||
func BootedUDID(ctx context.Context) string {
|
func BootedUDID(ctx context.Context) (string, error) {
|
||||||
d, _ := bootedSimulator(ctx)
|
d, err := bootedSimulator(ctx)
|
||||||
if d == nil {
|
if err != nil {
|
||||||
return ""
|
return "", err
|
||||||
}
|
}
|
||||||
return d.UDID
|
if d == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return d.UDID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootedSimulator(ctx context.Context) (*simDevice, error) {
|
func bootedSimulator(ctx context.Context) (*simDevice, error) {
|
||||||
|
|||||||
@@ -82,7 +82,10 @@ func TestPickSimulator_EmptyList(t *testing.T) {
|
|||||||
func TestBootedUDID_CanceledContext(t *testing.T) {
|
func TestBootedUDID_CanceledContext(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
cancel()
|
cancel()
|
||||||
udid := BootedUDID(ctx)
|
udid, err := BootedUDID(ctx)
|
||||||
|
if err == nil {
|
||||||
|
t.Error("expected error for canceled context, got nil")
|
||||||
|
}
|
||||||
if udid != "" {
|
if udid != "" {
|
||||||
t.Errorf("expected empty UDID on canceled context, got %q", udid)
|
t.Errorf("expected empty UDID on canceled context, got %q", udid)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver
|
|||||||
"--platform", options.Platform,
|
"--platform", options.Platform,
|
||||||
}
|
}
|
||||||
if options.Platform == "ios" {
|
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)
|
sidecarArgs = append(sidecarArgs, "--udid", udid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user