fix(testrun): delete a java check that was dead and wrong

preflightDevice was called only after web and both iOS branches had already
returned, so it never saw a platform other than android, and it returns nil for
anything but ios. The comment above the call said it was Android's java check;
Android's java check is in runPreflight. Its premise was wrong too: a physical
iOS device is runner-only over usbmux and needs no JVM. The replacement test
asserts an iOS host with no java passes preflight.

Also corrects two comments in the same file that still described iOS as routing
through the JVM sidecar, one of them naming an IosDriverBackend type that exists
nowhere in the tree.
This commit is contained in:
pj committed 2026-08-22 21:37:58 +05:30
1 parent 658574b568
commit a2dbcd1579
3 files changed
+12 -47

No files matched your search

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