8000 gh-130292: Allow for empty simulator list when running iOS testbed by freakboy3742 · Pull Request #130388 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

gh-130292: Allow for empty simulator list when running iOS testbed #130388

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

Merged
merged 4 commits into from
Feb 25, 2025
Merged
Changes from 1 commit
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
Next Next commit
Add error handling when there are no pre-existing test simulators.
  • Loading branch information
freakboy3742 committed Feb 20, 2025
commit fe01b9e90ab1bbb3dc6d767fdab0e90690c81348
36 changes: 23 additions & 13 deletions iOS/testbed/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,29 @@ async def async_check_output(*args, **kwargs):

# Return a list of UDIDs associated with booted simulators
async def list_devices():
# List the testing simulators, in JSON format
raw_json = await async_check_output(
"xcrun", "simctl", "--set", "testing", "list", "-j"
)
json_data = json.loads(raw_json)

# Filter out the booted iOS simulators
return [
simulator["udid"]
for runtime, simulators in json_data["devices"].items()
for simulator in simulators
if runtime.split(".")[-1].startswith("iOS") and simulator["state"] == "Booted"
]
try:
# List the testing simulators, in JSON format
raw_json = await async_check_output(
"xcrun", "simctl", "--set", "testing", "list", "-j"
)
json_data = json.loads(raw_json)

# Filter out the booted iOS simulators
return [
simulator["udid"]
for runtime, simulators in json_data["devices"].items()
for simulator in simulators
if runtime.split(".")[-1].startswith("iOS") and simulator["state"] == "Booted"
]
except subprocess.CalledProcessError as e:
# If there's no ~/Library/Developer/XCTestDevices folder (which is the
# case on fresh installs, and in some CI environments), `simctl list`
# returns error code 1, rather than an empty list. Handle that case,
# but raise all other errors.
if e.returncode == 1:
return []
else:
raise


async def find_device(initial_devices):
Expand Down
0