diff --git a/internal/testrun/driver.go b/internal/testrun/driver.go index caa1531..9c3c967 100644 --- a/internal/testrun/driver.go +++ b/internal/testrun/driver.go @@ -138,11 +138,6 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver return d, cleanup, nil } - // Android uses the JVM sidecar, which requires java. - if err := preflightDevice(options.Platform); err != nil { - return nil, nil, err - } - sidecarDirectory := os.TempDir() + "/sanderling-sidecar" jarPath, err := sidecarassets.Extract(sidecarDirectory) if err != nil { @@ -169,9 +164,8 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver sidecarCommand.Stdout = stdout sidecarCommand.Stderr = stdout sidecarCommand.Env = android.EnvWithAndroidPlatformTools(os.Environ(), adbPath) - // SIGTERM lets the sidecar's shutdown hook stop the iOS XCTest runner. - // SIGKILL skips the hook and orphans an xcodebuild session that later - // restarts its runner and hijacks the simulator mid-run. + // SIGTERM lets the sidecar run its shutdown hook. SIGKILL skips it and + // leaves the adb connection and the device-side instrumentation behind. sidecarCommand.Cancel = func() error { return sidecarCommand.Process.Signal(syscall.SIGTERM) } @@ -190,9 +184,9 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver } driverClient.SetPlatform(options.Platform) driverClient.SetClearStateReinstall(options.Device, options.AndroidAppPath, stdout) - // WaitForHealth confirms the gRPC sidecar is up. For iOS, the WDA warmup - // (absorbing the XCUITest startup race) runs inside IosDriverBackend.init - // in the sidecar - no additional sleep needed here. + // WaitForHealth confirms the gRPC sidecar is up. This path is Android + // only: iOS has not routed through the sidecar since the native companion + // replaced it, and buildDriver returns before reaching here. healthCtx, healthCancel := context.WithTimeout(ctx, sidecarStartupTimeout) healthErr := awaitSidecar(healthCtx, address, sidecarStartupTimeout, func(pollCtx context.Context) error { return driverClient.WaitForHealth(pollCtx, 250e6) diff --git a/internal/testrun/preflight.go b/internal/testrun/preflight.go index e95caf8..64984ef 100644 --- a/internal/testrun/preflight.go +++ b/internal/testrun/preflight.go @@ -51,8 +51,8 @@ func runPreflight(ctx context.Context, platform string, check preflightFunc) err } return nil case "ios": - // Simulator runs drive the native companion and need no JVM. The java - // requirement is deferred to the physical-device path in buildDriver. + // Neither iOS path needs a JVM: the simulator is driven by the native + // companion and a physical device runner-only over usbmux. if err := check("xcrun"); err != nil { return preflightFailure("ios", err) } @@ -62,25 +62,6 @@ func runPreflight(ctx context.Context, platform string, check preflightFunc) err } } -// preflightDevice runs the extra host checks the JVM sidecar path needs once we -// 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 := 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 -} - func preflightFailure(platform string, cause error) error { return fmt.Errorf( "preflight: %w\nrun `sanderling doctor --platform=%s` for full host-readiness checks", diff --git a/internal/testrun/preflight_test.go b/internal/testrun/preflight_test.go index d2f32f1..8ca2d1d 100644 --- a/internal/testrun/preflight_test.go +++ b/internal/testrun/preflight_test.go @@ -122,27 +122,17 @@ func TestPreflight_AllOK(t *testing.T) { } } -func TestPreflightDevice_NonIosIsNoop(t *testing.T) { - for _, platform := range []string{"web", "android"} { - if err := preflightDevice(platform); err != nil { - t.Errorf("%s: preflightDevice should be a no-op, got %v", platform, err) - } - } -} - -func TestPreflightDevice_JavaFailurePointsAtIosDeviceDoctor(t *testing.T) { +// Neither iOS path runs a JVM, so preflight must not turn a host away for +// want of java on the platform that never asks for it. +func TestPreflight_IosDoesNotRequireJava(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) + if err := runPreflight(context.Background(), "ios", check); err != nil { + t.Errorf("ios preflight failed on a host with no java: %v", err) } }