Skip to content

Commit

Permalink
Handle all retries being used the same way as if subprocess.run was u…
Browse files Browse the repository at this point in the history
…sed with check=True
  • Loading branch information
skottmckay committed Feb 26, 2024
1 parent c3dff6b commit 5c6efe2
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions tools/ci_build/github/apple/test_apple_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,23 @@ def _test_apple_packages(args):
# Add a couple of retries if we get this error:
# ios_package_testUITests-Runner Failed to initialize for UI testing:
# Error Domain=com.apple.dt.XCTest.XCTFuture Code=1000 "Timed out while loading Accessibility."
retries = 3
while retries > 0:
attempts = 0
cmd = [
"xcrun",
"xcodebuild",
"test",
"-workspace",
"./apple_package_test.xcworkspace",
"-scheme",
"ios_package_test",
"-destination",
f"platform=iOS Simulator,id={simulator_device_info['device_udid']}",
]

while True:
attempts += 1
completed_process = subprocess.run(
[
"xcrun",
"xcodebuild",
"test",
"-workspace",
"./apple_package_test.xcworkspace",
"-scheme",
"ios_package_test",
"-destination",
f"platform=iOS Simulator,id={simulator_device_info['device_udid']}",
],
cmd,
shell=False,
capture_output=True,
check=False,
Expand All @@ -164,10 +167,13 @@ def _test_apple_packages(args):
print(completed_process.stderr)
print("---")

if "Timed out while loading Accessibility" in completed_process.stderr:
retries -= 1
if "Timed out while loading Accessibility" in completed_process.stderr and attempts < 3:
continue

raise subprocess.CalledProcessError(
completed_process.returncode, " ".join(cmd), completed_process.stdout, completed_process.stderr
)

break

if PackageVariant[args.variant] != PackageVariant.Mobile and not args.skip_macos_test:
Expand Down

0 comments on commit 5c6efe2

Please sign in to comment.