https://github.com/python/cpython/commit/7998f998b215c994035ce6eb320fae5d447e1dd8
commit: 7998f998b215c994035ce6eb320fae5d447e1dd8
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: freakboy3742 <russ...@keith-magee.com>
date: 2025-04-29T21:59:21Z
summary:

[3.13] gh-133131: Discover an appropriate iOS simulator rather than hard-coding 
iPhone SE 3rd gen (GH-133132) (#133173)

Determines a candidate simulator at runtime rather than hardcoding iPhone SE.
(cherry picked from commit 42b0b0667e67ff444a03d0e7b217e77f3aae535d)

Co-authored-by: Russell Keith-Magee <russ...@keith-magee.com>

files:
A Misc/NEWS.d/next/Tests/2025-04-29-14-56-37.gh-issue-133131.1pchjl.rst
M iOS/testbed/__main__.py

diff --git 
a/Misc/NEWS.d/next/Tests/2025-04-29-14-56-37.gh-issue-133131.1pchjl.rst 
b/Misc/NEWS.d/next/Tests/2025-04-29-14-56-37.gh-issue-133131.1pchjl.rst
new file mode 100644
index 00000000000000..30b0f18f8dc925
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2025-04-29-14-56-37.gh-issue-133131.1pchjl.rst
@@ -0,0 +1,2 @@
+The iOS testbed will now select the most recently released "SE-class" device
+for testing if a device isn't explicitly specified.
diff --git a/iOS/testbed/__main__.py b/iOS/testbed/__main__.py
index b436c9af99d2c4..c05497ede3aa61 100644
--- a/iOS/testbed/__main__.py
+++ b/iOS/testbed/__main__.py
@@ -123,6 +123,36 @@ async def async_check_output(*args, **kwargs):
             )
 
 
+# Select a simulator device to use.
+async def select_simulator_device():
+    # 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)
+
+    # Any device will do; we'll look for "SE" devices - but the name isn't
+    # consistent over time. Older Xcode versions will use "iPhone SE (Nth
+    # generation)"; As of 2025, they've started using "iPhone 16e".
+    #
+    # When Xcode is updated after a new release, new devices will be available
+    # and old ones will be dropped from the set available on the latest iOS
+    # version. Select the one with the highest minimum runtime version - this
+    # is an indicator of the "newest" released device, which should always be
+    # supported on the "most recent" iOS version.
+    se_simulators = sorted(
+        (devicetype["minRuntimeVersion"], devicetype["name"])
+        for devicetype in json_data["devicetypes"]
+        if devicetype["productFamily"] == "iPhone"
+        and (
+            ("iPhone " in devicetype["name"] and 
devicetype["name"].endswith("e"))
+            or "iPhone SE " in devicetype["name"]
+        )
+    )
+
+    return se_simulators[-1][1]
+
+
 # Return a list of UDIDs associated with booted simulators
 async def list_devices():
     try:
@@ -371,12 +401,16 @@ def update_plist(testbed_path, args):
         plistlib.dump(info, f)
 
 
-async def run_testbed(simulator: str, args: list[str], verbose: bool=False):
+async def run_testbed(simulator: str | None, args: list[str], verbose: 
bool=False):
     location = Path(__file__).parent
     print("Updating plist...", end="", flush=True)
     update_plist(location, args)
     print(" done.", flush=True)
 
+    if simulator is None:
+        simulator = await select_simulator_device()
+    print(f"Running test on {simulator}", flush=True)
+
     # We need to get an exclusive lock on simulator creation, to avoid issues
     # with multiple simulators starting and being unable to tell which
     # simulator is due to which testbed instance. See
@@ -453,8 +487,10 @@ def main():
     )
     run.add_argument(
         "--simulator",
-        default="iPhone SE (3rd Generation)",
-        help="The name of the simulator to use (default: 'iPhone SE (3rd 
Generation)')",
+        help=(
+            "The name of the simulator to use (eg: 'iPhone 16e'). Defaults to 
",
+            "the most recently released 'entry level' iPhone device."
+        )
     )
     run.add_argument(
         "-v", "--verbose",

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to