From 7402eefa67e751646835719f8139757b809effc9 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Wed, 13 Nov 2024 15:50:10 -0600 Subject: [PATCH] Fix Signed-off-by: Brentley Jones --- .../default_runner/simulator_creator.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apple/testing/default_runner/simulator_creator.py b/apple/testing/default_runner/simulator_creator.py index 5cdfc5d72..4cd5fc987 100755 --- a/apple/testing/default_runner/simulator_creator.py +++ b/apple/testing/default_runner/simulator_creator.py @@ -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"] @@ -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)