From a203302b004c51881ca4a8b7fa04923b079a5682 Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 7 Jun 2026 21:39:23 +0530 Subject: [PATCH] fix(testrun): point the device java preflight hint at the ios-device doctor --- internal/testrun/preflight.go | 10 ++++++++-- internal/testrun/preflight_test.go | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/internal/testrun/preflight.go b/internal/testrun/preflight.go index 87dc88a..a65c88b 100644 --- a/internal/testrun/preflight.go +++ b/internal/testrun/preflight.go @@ -56,11 +56,17 @@ func runPreflight(ctx context.Context, platform string, check preflightFunc) err // know a run targets a physical iOS device. Android already requires java in // the top-level Preflight, so this only matters for ios. func preflightDevice(platform string) error { + return runPreflightDevice(platform, preflightCheck) +} + +func runPreflightDevice(platform string, check preflightFunc) error { if platform != "ios" { return nil } - if err := preflightCheck("java"); err != nil { - return preflightFailure("ios", err) + if err := check("java"); err != nil { + // The doctor splits simulator and device checks: java lives under the + // ios-device platform, so the hint must point there. + return preflightFailure("ios-device", err) } return nil } diff --git a/internal/testrun/preflight_test.go b/internal/testrun/preflight_test.go index a213303..e460d07 100644 --- a/internal/testrun/preflight_test.go +++ b/internal/testrun/preflight_test.go @@ -101,6 +101,22 @@ func TestPreflightDevice_NonIosIsNoop(t *testing.T) { } } +func TestPreflightDevice_JavaFailurePointsAtIosDeviceDoctor(t *testing.T) { + check := func(name string) error { + if name == "java" { + return errors.New("java not found") + } + return nil + } + err := runPreflightDevice("ios", check) + if err == nil || !strings.Contains(err.Error(), "java") { + t.Fatalf("expected java error, got %v", err) + } + if !strings.Contains(err.Error(), "sanderling doctor --platform=ios-device") { + t.Errorf("hint must name the ios-device doctor platform: %v", err) + } +} + func TestPreflight_UnknownPlatform(t *testing.T) { check := func(string) error { return nil } if err := runPreflight(context.Background(), "fuchsia", check); err == nil {