Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ios-simulator-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions devices/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
24 changes: 0 additions & 24 deletions devices/ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
}

// wait 1 second after pressing home, so we make sure wda is in the background
d.wdaClient.PressButton("HOME")

Check failure on line 270 in devices/ios.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `d.wdaClient.PressButton` is not checked (errcheck)
time.Sleep(1 * time.Second)

utils.Verbose("WebDriverAgent started")
Expand Down Expand Up @@ -304,7 +304,7 @@
if err != nil {
return goios.DeviceEntry{}, fmt.Errorf("could not connect to RSD: %w", err)
}
defer rsdService.Close()

Check failure on line 307 in devices/ios.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `rsdService.Close` is not checked (errcheck)

rsdProvider, err := rsdService.Handshake()
if err != nil {
Expand Down Expand Up @@ -366,30 +366,6 @@
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")
Expand All @@ -406,7 +382,7 @@
if err != nil {
return fmt.Errorf("processcontrol failed: %w", err)
}
defer pControl.Close()

Check failure on line 385 in devices/ios.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `pControl.Close` is not checked (errcheck)

opts := map[string]any{}
args := []interface{}{}
Expand Down Expand Up @@ -437,7 +413,7 @@
if err != nil {
return fmt.Errorf("processcontrol failed: %w", err)
}
defer pControl.Close()

Check failure on line 416 in devices/ios.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `pControl.Close` is not checked (errcheck)

svc, err := installationproxy.New(device)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions devices/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@
}

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
Expand All @@ -232,13 +232,13 @@
if err != nil {
return "", fmt.Errorf("failed to create temp file: %v", err)
}
tmpFile.Close()

Check failure on line 235 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `tmpFile.Close` is not checked (errcheck)

log.Printf("Downloading WebDriverAgent to: %s", tmpFile.Name())

err = utils.DownloadFile(url, tmpFile.Name())
if err != nil {
os.Remove(tmpFile.Name())

Check failure on line 241 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `os.Remove` is not checked (errcheck)
return "", fmt.Errorf("failed to download WebDriverAgent: %v", err)
}

Expand All @@ -252,7 +252,7 @@
return fmt.Errorf("failed to download WebDriverAgent: %v", err)
}

defer os.Remove(file)

Check failure on line 255 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `os.Remove` is not checked (errcheck)

log.Printf("Downloaded WebDriverAgent to %s", file)

Expand All @@ -261,7 +261,7 @@
return fmt.Errorf("failed to unzip WebDriverAgent: %v", err)
}

defer os.RemoveAll(dir)

Check failure on line 264 in devices/simulator.go

View workflow job for this annotation

GitHub Actions / test_and_lint

Error return value of `os.RemoveAll` is not checked (errcheck)
log.Printf("Unzipped WebDriverAgent to %s", dir)

err = InstallApp(s.UDID, dir+"/WebDriverAgentRunner-Runner.app")
Expand Down
4 changes: 2 additions & 2 deletions test/simctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 4 additions & 12 deletions test/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand All @@ -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}`);
}
Expand All @@ -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 {
Expand All @@ -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}`);
}

Loading