From b214df4b9dd1f103c13e66345fe978e0bd440593 Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 9 Jun 2026 18:36:19 +0530 Subject: [PATCH] fix(testrun): seam preflight so iOS routing tests pass on CI without xcrun --- internal/testrun/driver.go | 6 +++++- internal/testrun/driver_test.go | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/testrun/driver.go b/internal/testrun/driver.go index 2d31d0b..c155e22 100644 --- a/internal/testrun/driver.go +++ b/internal/testrun/driver.go @@ -69,6 +69,10 @@ func resolveIOSTarget(ctx context.Context, options Options, stdout io.Writer) (O return options, nil } +// preflight is a seam so routing tests exercise driver construction without the +// host-readiness checks (xcrun, java) that are absent on a Linux CI runner. +var preflight = Preflight + // newDeviceDriver constructs the physical-device iOS driver and its cleanup. A // seam so routing tests assert the resolved identifiers reach DeviceOptions // without building or spawning a real runner. @@ -86,7 +90,7 @@ var newDeviceDriver = func(ctx context.Context, options ioscompanion.DeviceOptio // is driven runner-only over a usbmux tunnel. Android uses the JVM sidecar, // which is extracted, spawned, and dialed. func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver.DeviceDriver, func(), error) { - if err := Preflight(ctx, options.Platform); err != nil { + if err := preflight(ctx, options.Platform); err != nil { return nil, nil, err } if options.Platform == "web" { diff --git a/internal/testrun/driver_test.go b/internal/testrun/driver_test.go index 78d1510..5e461b3 100644 --- a/internal/testrun/driver_test.go +++ b/internal/testrun/driver_test.go @@ -16,6 +16,7 @@ import ( type stubDeviceDriver struct{ driver.DeviceDriver } func TestBuildDriverRoutesPhysicalIOSToDeviceDriver(t *testing.T) { + stubPreflight(t) original := newDeviceDriver t.Cleanup(func() { newDeviceDriver = original }) @@ -51,6 +52,7 @@ func TestBuildDriverRoutesPhysicalIOSToDeviceDriver(t *testing.T) { } func TestBuildDriverSurfacesDeviceConstructionError(t *testing.T) { + stubPreflight(t) original := newDeviceDriver t.Cleanup(func() { newDeviceDriver = original }) newDeviceDriver = func(context.Context, ioscompanion.DeviceOptions) (driver.DeviceDriver, func(), error) { @@ -63,6 +65,15 @@ func TestBuildDriverSurfacesDeviceConstructionError(t *testing.T) { } } +// stubPreflight bypasses the host-readiness checks so routing tests exercise +// driver construction on a Linux CI runner that lacks xcrun/java. +func stubPreflight(t *testing.T) { + t.Helper() + original := preflight + t.Cleanup(func() { preflight = original }) + preflight = func(context.Context, string) error { return nil } +} + func swapIOSResolveSeams(t *testing.T) { t.Helper() origTarget, origDevice, origEnsure := iosResolveTarget, iosResolveDevice, iosEnsureSimulator