mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-130292: Allow for empty simulator list when running iOS testbed (#130388)
Adds error handling when there are no pre-existing test simulators.
This commit is contained in:
parent
56e337d32b
commit
99088ab081
2 changed files with 24 additions and 12 deletions
|
@ -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)
|
||||
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"
|
||||
]
|
||||
# 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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue