-
-
Notifications
You must be signed in to change notification settings - Fork 230
chore: Mitigate iOS device test timeouts #5063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9cf103f
7079f36
70ec4ff
ffbfcd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,37 @@ | ||
| function Reset-IosSimulator { | ||
| [CmdletBinding()] | ||
| param( | ||
| [Parameter(Mandatory)] | ||
| [PSCustomObject]$SimInfo | ||
| ) | ||
|
|
||
| $udid = $SimInfo.Udid | ||
|
|
||
| Write-Host "Hard-resetting simulator $($SimInfo.Name) [$udid]..." | ||
|
|
||
| # Shut down & delete the old device | ||
| xcrun simctl shutdown $udid 2>&1 | Out-Null | ||
| xcrun simctl delete $udid 2>&1 | Out-Null | ||
|
|
||
| # Restart the CoreSimulator service to clear any daemon-level state left | ||
| # over from a simulator crash (this is what makes a fresh runner "work"). | ||
| Write-Host "Restarting CoreSimulator service..." | ||
| sudo launchctl kickstart -kp system/com.apple.CoreSimulator.CoreSimulatorService 2>&1 | Out-Null | ||
| Start-Sleep -Seconds 5 # give the daemon time to re-initialise | ||
|
|
||
| # Create a brand-new simulator with the same device type & runtime | ||
| $newUdid = (& xcrun simctl create $SimInfo.Name $SimInfo.DeviceType $SimInfo.Runtime).Trim() | ||
|
Check warning on line 23 in scripts/device-test-utils.ps1
|
||
| Write-Host "Created new simulator $($SimInfo.Name) [$newUdid]" | ||
|
|
||
| # Boot and wait | ||
| xcrun simctl boot $newUdid 2>&1 | Out-Null | ||
| xcrun simctl bootstatus $newUdid -b | ||
|
|
||
| # Return updated info | ||
| $SimInfo.Udid = $newUdid | ||
| return $newUdid | ||
| } | ||
|
|
||
| function Install-XHarness | ||
| { | ||
| if (!(Get-Command xharness -ErrorAction SilentlyContinue)) | ||
|
|
@@ -120,5 +154,10 @@ | |
| } | ||
|
|
||
| Write-Verbose ("Selected simulator: {0} ({1}) [{2}]" -f $selected.Device.name, $selected.Device.deviceTypeIdentifier, $selected.Device.udid) | ||
| return $selected.Device.udid | ||
| return [PSCustomObject]@{ | ||
| Udid = $selected.Device.udid | ||
| Name = $selected.Device.name | ||
| DeviceType = $selected.Device.deviceTypeIdentifier | ||
| Runtime = $runtimeKey | ||
| } | ||
|
Check failure on line 162 in scripts/device-test-utils.ps1
|
||
|
Comment on lines
+157
to
+162
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Breaking change: Get-IosSimulatorUdid return type change breaks ios.Tests.ps1 The function VerificationRead scripts/device-test-utils.ps1 to see the return type change from string to PSCustomObject. Read integration-test/ios.Tests.ps1 which calls Get-IosSimulatorUdid at line 11 and uses $simulator directly at lines 43, 53-54, 68-69, 70-74 with xcrun simctl commands. Confirmed ios.Tests.ps1 is not in the list of files modified in this PR, meaning it won't be updated to handle the new return type. Identified by Warden |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error check on xcrun simctl create can cause cascading failures with invalid UDID
Line 23 captures the output of
xcrun simctl createbut does not check$LASTEXITCODE. If the create command fails (e.g., invalid DeviceType/Runtime, or resource exhaustion), the error message text becomes the$newUdidvalue. Subsequent operations at lines 27-28 will attempt to boot this garbage string as a UDID, and line 32 returns it to the caller, causing hard-to-diagnose CI failures.Verification
Read Reset-IosSimulator function completely. Traced flow from xcrun simctl create at line 23 through simctl boot at line 27 and return at line 32. Confirmed no $LASTEXITCODE check or try/catch around the create operation. Compared with other functions in the file which also lack such checks.
Identified by Warden
find-bugs·4YX-2ML