mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
refactor(testrun): defer the java preflight check to the physical-device path
This commit is contained in:
1 parent
75d4294601
commit
20dab0ae2f
2 files changed
+43
-4
No files matched your search
@@ -41,18 +41,30 @@ 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.
|
||||
if err := check("xcrun"); err != nil {
|
||||
return preflightFailure("ios", err)
|
||||
}
|
||||
if err := check("java"); err != nil {
|
||||
return preflightFailure("ios", err)
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("preflight: unknown platform %q", platform)
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
if platform != "ios" {
|
||||
return nil
|
||||
}
|
||||
if err := preflightCheck("java"); err != nil {
|
||||
return preflightFailure("ios", 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",
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestPreflight_AndroidNeedsAdbAndJava(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreflight_iOSNeedsXcrunAndJava(t *testing.T) {
|
||||
func TestPreflight_iOSNeedsXcrun(t *testing.T) {
|
||||
check := func(name string) error {
|
||||
if name == "xcrun" {
|
||||
return errors.New("xcrun not found")
|
||||
@@ -65,6 +65,25 @@ func TestPreflight_iOSNeedsXcrunAndJava(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreflight_iOSDoesNotRequireJava(t *testing.T) {
|
||||
checked := []string{}
|
||||
check := func(name string) error {
|
||||
checked = append(checked, name)
|
||||
if name == "java" {
|
||||
return errors.New("java not found")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := runPreflight(context.Background(), "ios", check); err != nil {
|
||||
t.Fatalf("ios preflight should pass without java, got %v", err)
|
||||
}
|
||||
for _, name := range checked {
|
||||
if name == "java" {
|
||||
t.Errorf("ios preflight must not check java; simulator runs need no JVM")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreflight_AllOK(t *testing.T) {
|
||||
check := func(name string) error { return nil }
|
||||
for _, platform := range []string{"web", "android", "ios"} {
|
||||
@@ -74,6 +93,14 @@ 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 TestPreflight_UnknownPlatform(t *testing.T) {
|
||||
check := func(string) error { return nil }
|
||||
if err := runPreflight(context.Background(), "fuchsia", check); err == nil {
|
||||
|
||||
Reference in new issue
Block a user