diff --git a/.github/workflows/ios-simulator-test.yml b/.github/workflows/ios-simulator-test.yml index e1e3dae..18774a9 100644 --- a/.github/workflows/ios-simulator-test.yml +++ b/.github/workflows/ios-simulator-test.yml @@ -34,7 +34,6 @@ jobs: - name: Download iOS ${{ matrix.ios_version }} runtime run: | xcodebuild -downloadPlatform iOS -buildVersion ${{ matrix.build_version }} - continue-on-error: true - name: Set up Go uses: actions/setup-go@v5 diff --git a/devices/common.go b/devices/common.go index 53c626a..d25ec4e 100644 --- a/devices/common.go +++ b/devices/common.go @@ -39,33 +39,29 @@ type ControllableDevice interface { // and returns them as a slice of ControllableDevice. func GetAllControllableDevices() ([]ControllableDevice, error) { var allDevices []ControllableDevice - var errs []error - // Get Android devices + // get Android devices androidDevices, err := GetAndroidDevices() // Assumes this now returns []ControllableDevice if err != nil { - // Log or collect error, decide if it's fatal or if we continue utils.Verbose("Warning: Failed to get Android devices: %v", err) - errs = append(errs, fmt.Errorf("android: %w", err)) } else { allDevices = append(allDevices, androidDevices...) } - // Get iOS real devices + // get iOS real devices iosDevices, err := ListIOSDevices() if err != nil { utils.Verbose("Warning: Failed to get iOS real devices: %v", err) - errs = append(errs, fmt.Errorf("ios real: %w", err)) } else { for _, device := range iosDevices { allDevices = append(allDevices, &device) } } + // get iOS simulator devices sims, err := GetBootedSimulators() if err != nil { utils.Verbose("Warning: Failed to get iOS simulators: %v", err) - errs = append(errs, fmt.Errorf("ios simulator: %w", err)) } else { for _, sim := range sims { allDevices = append(allDevices, &SimulatorDevice{ diff --git a/devices/ios.go b/devices/ios.go index f9f7983..2a8ea17 100644 --- a/devices/ios.go +++ b/devices/ios.go @@ -366,30 +366,6 @@ func (d IOSDevice) getEnhancedDevice() (goios.DeviceEntry, error) { return device, nil } -// Legacy function kept for compatibility - now just calls the method -func getEnhancedDevice(udid string) (goios.DeviceEntry, error) { - device, err := goios.GetDevice(udid) - if err != nil { - return goios.DeviceEntry{}, fmt.Errorf("device not found: %s: %w", udid, err) - } - - // Fallback to HTTP API only - no access to tunnel manager from standalone function - info, err := tunnel.TunnelInfoForDevice(device.Properties.SerialNumber, "localhost", 60105) - if err == nil { - device.UserspaceTUNPort = info.UserspaceTUNPort - device.UserspaceTUNHost = "localhost" - device.UserspaceTUN = info.UserspaceTUN - device, err = deviceWithRsdProvider(device, udid, info.Address, info.RsdPort) - if err != nil { - utils.Verbose("failed to get device with RSD provider: %v", err) - } - } else { - utils.Verbose("failed to get tunnel info for device %s: %v", udid, err) - } - - return device, nil -} - func (d IOSDevice) LaunchApp(bundleID string) error { if bundleID == "" { return fmt.Errorf("bundleID cannot be empty") diff --git a/devices/simulator.go b/devices/simulator.go index 0b58e64..400030c 100644 --- a/devices/simulator.go +++ b/devices/simulator.go @@ -205,13 +205,13 @@ func (s SimulatorDevice) ListInstalledApps() (map[string]interface{}, error) { } func (s SimulatorDevice) WaitUntilAppExists(bundleID string) error { - installedApps, err := s.ListInstalledApps() - if err != nil { - return fmt.Errorf("failed to list installed apps: %v", err) - } - startTime := time.Now() for { + installedApps, err := s.ListInstalledApps() + if err != nil { + return fmt.Errorf("failed to list installed apps: %v", err) + } + _, ok := installedApps[bundleID] if ok { return nil diff --git a/test/simctl.ts b/test/simctl.ts index 53895ee..1fda02d 100644 --- a/test/simctl.ts +++ b/test/simctl.ts @@ -55,8 +55,8 @@ export function waitForSimulatorReady(simulatorId: string, timeout: number = 300 const stdout = execSync(`xcrun simctl list devices | grep "${simulatorId}"`, { encoding: 'utf8' }); if (stdout.includes('(Booted)')) { - // Give it a bit more time to fully initialize - execSync('sleep 2'); + // see if we can interact with status_bar, gets us closer to a functioning simulator + execSync(`xcrun simctl status_bar "${simulatorId}" list`); return; } } catch (error) { diff --git a/test/simulator.ts b/test/simulator.ts index 03ae0b8..5dc65ca 100644 --- a/test/simulator.ts +++ b/test/simulator.ts @@ -94,9 +94,7 @@ describe('iOS Simulator Tests', () => { }); }); -// Screenshot test helper functions with descriptive English names - -function mobilecli(args: string, description: string): void { +function mobilecli(args: string): void { const mobilecliBinary = path.join(__dirname, '..', 'mobilecli'); const command = `${mobilecliBinary} ${args}`; @@ -107,7 +105,7 @@ function mobilecli(args: string, description: string): void { stdio: ['pipe', 'pipe', 'pipe'] }); } catch (error: any) { - console.log(`${description} command failed: ${command}`); + console.log(`Command failed: ${command}`); if (error.stderr) { console.log(`Error stderr: ${error.stderr}`); } @@ -122,10 +120,7 @@ function mobilecli(args: string, description: string): void { } function takeScreenshot(simulatorId: string, screenshotPath: string): void { - mobilecli( - `screenshot --device ${simulatorId} --format png --output ${screenshotPath}`, - 'Screenshot' - ); + mobilecli(`screenshot --device ${simulatorId} --format png --output ${screenshotPath}`); } function verifyScreenshotFileWasCreated(screenshotPath: string): void { @@ -142,9 +137,6 @@ function verifyScreenshotFileHasValidContent(screenshotPath: string): void { } function openUrl(simulatorId: string, url: string): void { - mobilecli( - `url "${url}" --device ${simulatorId}`, - 'URL' - ); + mobilecli(`url "${url}" --device ${simulatorId}`); }