fix(testrun): simctl-first launch order for iOS; Maestro init after SDK connects

This commit is contained in:
pj committed 2026-04-23 15:15:23 +07:00
1 parent 016a959833
commit c9aa1683df
1 file changed
+8 -5
+8 -5
View File
@@ -133,14 +133,11 @@ func Execute(ctx context.Context, options Options, stdout io.Writer) error {
defer listener.Close()
agentPort := listener.Addr().(*net.TCPAddr).Port
// Start Maestro XCTest session, then re-launch via simctl to inject the port.
if err := activeDriver.Launch(ctx, options.BundleID, false); err != nil {
return fmt.Errorf("launch app (maestro): %w", err)
}
// Launch app via simctl with SANDERLING_PORT so the SDK can connect.
if err := ios.LaunchApp(ctx, options.BundleID, map[string]string{
"SANDERLING_PORT": strconv.Itoa(agentPort),
}); err != nil {
return fmt.Errorf("launch app (simctl): %w", err)
return fmt.Errorf("launch app: %w", err)
}
fmt.Fprintf(stdout, "iOS app launched with SANDERLING_PORT=%d; waiting for SDK (%.0fs timeout)\n", agentPort, sdkAcceptTimeout.Seconds())
@@ -156,6 +153,12 @@ func Execute(ctx context.Context, options Options, stdout io.Writer) error {
hello := connection.Hello()
fmt.Fprintf(stdout, "SDK connected: platform=%s app=%s sdk=%s\n", hello.Platform, hello.AppPackage, hello.Version)
// Initialize Maestro XCTest session after the app is running.
// clearState=false avoids relaunching the already-connected app.
if err := activeDriver.Launch(ctx, options.BundleID, false); err != nil {
fmt.Fprintf(stdout, "warn: maestro launch: %v\n", err)
}
case "web":
fmt.Fprintln(stdout, "web mode: skipping SDK")
if err := activeDriver.Launch(ctx, options.BundleID, false); err != nil {