]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-140702: Add test skip for Unix Datagram tests on iOS when on Github Actions...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 29 Oct 2025 09:01:39 +0000 (10:01 +0100)
committerGitHub <noreply@github.com>
Wed, 29 Oct 2025 09:01:39 +0000 (09:01 +0000)
Exposes the GITHUB_ACTIONS environment variable to iOS simulator test runs, and
uses this variable to skip a Unix Datagram socketserver test that is unreliable
in the iOS GitHub Actions environment.
(cherry picked from commit 9f8d005d2961777aa533ec330f96b50324a3446f)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Apple/iOS/README.md
Apple/testbed/TestbedTests/TestbedTests.m
Apple/testbed/__main__.py
Lib/test/support/__init__.py
Lib/test/test_socketserver.py
Misc/NEWS.d/next/Tools-Demos/2025-10-29-15-20-19.gh-issue-140702.ZXtW8h.rst [new file with mode: 0644]

index 124a05657aae09d2cf3fee9dbe40c0243df62d3e..7ee257b5d648f46729fbbb989bcf7f58011fb734 100644 (file)
@@ -224,6 +224,17 @@ Once you have a built an XCframework, you can test that framework by running:
 
   $ python Apple test iOS
 
+This test will attempt to find an "SE-class" simulator (i.e., an iPhone SE, or
+iPhone 16e, or similar), and run the test suite on the most recent version of
+iOS that is available. You can specify a simulator using the `--simulator`
+command line argument, providing the name of the simulator (e.g., `--simulator
+'iPhone 16 Pro'`). You can also use this argument to control the OS version used
+for testing; `--simulator 'iPhone 16 Pro,OS=18.2'` would attempt to run the
+tests on an iPhone 16 Pro running iOS 18.2.
+
+If the test runner is executed on GitHub Actions, the `GITHUB_ACTIONS`
+environment variable will be exposed to the iOS process at runtime.
+
 ### Testing a single-architecture framework
 
 The `Apple/testbed` folder that contains an Xcode project that is able to run
index 80741097e4c80d6c5a51d6c97a4d2d3f743e3eff..f7788c47f2c22965025ba189f4d0e36464bccf80 100644 (file)
@@ -35,6 +35,9 @@
     setenv("NO_COLOR", "1", true);
     setenv("PYTHON_COLORS", "0", true);
 
+    if (getenv("GITHUB_ACTIONS")) {
+        NSLog(@"Running in a GitHub Actions environment");
+    }
     // Arguments to pass into the test suite runner.
     // argv[0] must identify the process; any subsequent arg
     // will be handled as if it were an argument to `python -m test`
index f3407ecdf7e7345dc772d545aa0ba12aa294f0c5..42eb60a4c8dc02e972818123159463f4f6ac4b7e 100644 (file)
@@ -1,5 +1,6 @@
 import argparse
 import json
+import os
 import re
 import shutil
 import subprocess
@@ -78,6 +79,13 @@ def xcode_test(location: Path, platform: str, simulator: str, verbose: bool):
         check=True,
     )
 
+    # Any environment variable prefixed with TEST_RUNNER_ is exposed into the
+    # test runner environment. There are some variables (like those identifying
+    # CI platforms) that can be useful to have access to.
+    test_env = os.environ.copy()
+    if "GITHUB_ACTIONS" in os.environ:
+        test_env["TEST_RUNNER_GITHUB_ACTIONS"] = os.environ["GITHUB_ACTIONS"]
+
     print("Running test project...")
     # Test execution *can't* be run -quiet; verbose mode
     # is how we see the output of the test output.
@@ -85,6 +93,7 @@ def xcode_test(location: Path, platform: str, simulator: str, verbose: bool):
         ["xcodebuild", "test-without-building"] + args,
         stdout=subprocess.PIPE,
         stderr=subprocess.STDOUT,
+        env=test_env,
     )
     while line := (process.stdout.readline()).decode(*DECODE_ARGS):
         # Strip the timestamp/process prefix from each log line
index 88f6110351245982040d824411f39690ea42d0ff..da72b0c7dab878d38e52b8814ea4229c0d801c28 100644 (file)
@@ -68,7 +68,7 @@ __all__ = [
     "BrokenIter",
     "in_systemd_nspawn_sync_suppressed",
     "run_no_yield_async_fn", "run_yielding_async_fn", "async_yield",
-    "reset_code",
+    "reset_code", "on_github_actions"
     ]
 
 
@@ -1370,6 +1370,7 @@ def reset_code(f: types.FunctionType) -> types.FunctionType:
     f.__code__ = f.__code__.replace()
     return f
 
+on_github_actions = "GITHUB_ACTIONS" in os.environ
 
 #=======================================================================
 # Check for the presence of docstrings.
index 0f62f9eb200e42ddb4303fadc675e78b5b8f66bc..2ca356606b260cbc6fa2ed7e39a3f4624f346eb1 100644 (file)
@@ -218,12 +218,16 @@ class SocketServerTest(unittest.TestCase):
                             self.dgram_examine)
 
     @requires_unix_sockets
+    @unittest.skipIf(test.support.is_apple_mobile and test.support.on_github_actions,
+                     "gh-140702: Test fails regularly on iOS simulator on GitHub Actions")
     def test_UnixDatagramServer(self):
         self.run_server(socketserver.UnixDatagramServer,
                         socketserver.DatagramRequestHandler,
                         self.dgram_examine)
 
     @requires_unix_sockets
+    @unittest.skipIf(test.support.is_apple_mobile and test.support.on_github_actions,
+                     "gh-140702: Test fails regularly on iOS simulator on GitHub Actions")
     def test_ThreadingUnixDatagramServer(self):
         self.run_server(socketserver.ThreadingUnixDatagramServer,
                         socketserver.DatagramRequestHandler,
diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-10-29-15-20-19.gh-issue-140702.ZXtW8h.rst b/Misc/NEWS.d/next/Tools-Demos/2025-10-29-15-20-19.gh-issue-140702.ZXtW8h.rst
new file mode 100644 (file)
index 0000000..9efbf01
--- /dev/null
@@ -0,0 +1,2 @@
+The iOS testbed app will now expose the ``GITHUB_ACTIONS`` environment
+variable to iOS apps being tested.