mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
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:
1 parent
658574b568
commit
a2dbcd1579
3 files changed
+12
-47
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user