Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Brentley Jones <[email protected]>
  • Loading branch information
brentleyjones committed Nov 13, 2024
1 parent ab0d4a7 commit 7402eef
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions apple/testing/default_runner/simulator_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ def _boot_simulator(simulator_id: str) -> None:
output = _simctl(["bootstatus", simulator_id, "-b"])
print(output, file=sys.stderr)
except subprocess.CalledProcessError as e:
exit_code = e.returncode

# When reusing simulators we may encounter the error:
# 'Unable to boot device in current state: Booted'.
#
# This is because the simulator is already booted, and we can ignore it
# if we check and the simulator is in fact booted.
if e.returncode == 149:
if exit_code == 149:
devices = json.loads(
_simctl(["list", "devices", "-j", simulator_id]),
)["devices"]
Expand All @@ -54,17 +56,23 @@ def _boot_simulator(simulator_id: str) -> None:
f"Simulator '{device['name']}' ({simulator_id}) is already booted",
file=sys.stderr,
)
exit_code = 0

# Both of these errors translate to strange simulator states that may
# end up causing issues, but attempting to actually use the simulator
# instead of failing at this point might still succeed
#
# 164: EBADDEVICE
# 165: EBADDEVICESTATE
elif e.returncode in (164, 165):
print(f"Ignoring a failure: {e.returncode}", file=sys.stderr)
else:
print(f"Not ignoring failure: {e.returncode}", file=sys.stderr)
if exit_code in (164, 165):
print(
f"Ignoring 'simctl bootstatus' exit code {exit_code}",
file=sys.stderr,
)
elif exit_code != 0:
print(f"'simctl bootstatus' exit code {exit_code}", file=sys.stderr)
raise

# Add more arbitrary delay before tests run. Even bootstatus doesn't wait
# long enough and tests can still fail because the simulator isn't ready
time.sleep(3)
Expand Down

0 comments on commit 7402eef

Please sign in to comment.