gh-140702: Add test skip for Unix Datagram tests on iOS when on Githu… · python/cpython@9f8d005

File tree

6 files changed

lines changed

  • Misc/NEWS.d/next/Tools-Demos

6 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -224,6 +224,17 @@ Once you have a built an XCframework, you can test that framework by running:

224224
225225

$ python Apple test iOS

226226
227+

This test will attempt to find an "SE-class" simulator (i.e., an iPhone SE, or

228+

iPhone 16e, or similar), and run the test suite on the most recent version of

229+

iOS that is available. You can specify a simulator using the `--simulator`

230+

command line argument, providing the name of the simulator (e.g., `--simulator

231+

'iPhone 16 Pro'`). You can also use this argument to control the OS version used

232+

for testing; `--simulator 'iPhone 16 Pro,OS=18.2'` would attempt to run the

233+

tests on an iPhone 16 Pro running iOS 18.2.

234+
235+

If the test runner is executed on GitHub Actions, the `GITHUB_ACTIONS`

236+

environment variable will be exposed to the iOS process at runtime.

237+
227238

### Testing a single-architecture framework

228239
229240

The `Apple/testbed` folder that contains an Xcode project that is able to run

Original file line numberDiff line numberDiff line change

@@ -35,6 +35,9 @@ - (void)testPython {

3535

setenv("NO_COLOR", "1", true);

3636

setenv("PYTHON_COLORS", "0", true);

3737
38+

if (getenv("GITHUB_ACTIONS")) {

39+

NSLog(@"Running in a GitHub Actions environment");

40+

}

3841

// Arguments to pass into the test suite runner.

3942

// argv[0] must identify the process; any subsequent arg

4043

// will be handled as if it were an argument to `python -m test`

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

import argparse

22

import json

3+

import os

34

import re

45

import shutil

56

import subprocess

@@ -78,13 +79,21 @@ def xcode_test(location: Path, platform: str, simulator: str, verbose: bool):

7879

check=True,

7980

)

8081
82+

# Any environment variable prefixed with TEST_RUNNER_ is exposed into the

83+

# test runner environment. There are some variables (like those identifying

84+

# CI platforms) that can be useful to have access to.

85+

test_env = os.environ.copy()

86+

if "GITHUB_ACTIONS" in os.environ:

87+

test_env["TEST_RUNNER_GITHUB_ACTIONS"] = os.environ["GITHUB_ACTIONS"]

88+
8189

print("Running test project...")

8290

# Test execution *can't* be run -quiet; verbose mode

8391

# is how we see the output of the test output.

8492

process = subprocess.Popen(

8593

["xcodebuild", "test-without-building"] + args,

8694

stdout=subprocess.PIPE,

8795

stderr=subprocess.STDOUT,

96+

env=test_env,

8897

)

8998

while line := (process.stdout.readline()).decode(*DECODE_ARGS):

9099

# Strip the timestamp/process prefix from each log line

Original file line numberDiff line numberDiff line change

@@ -68,7 +68,7 @@

6868

"BrokenIter",

6969

"in_systemd_nspawn_sync_suppressed",

7070

"run_no_yield_async_fn", "run_yielding_async_fn", "async_yield",

71-

"reset_code",

71+

"reset_code", "on_github_actions"

7272

]

7373
7474

@@ -1369,6 +1369,7 @@ def reset_code(f: types.FunctionType) -> types.FunctionType:

13691369

f.__code__ = f.__code__.replace()

13701370

return f

13711371
1372+

on_github_actions = "GITHUB_ACTIONS" in os.environ

13721373
13731374

#=======================================================================

13741375

# Check for the presence of docstrings.

Original file line numberDiff line numberDiff line change

@@ -223,12 +223,16 @@ def test_ForkingUDPServer(self):

223223

self.dgram_examine)

224224
225225

@requires_unix_sockets

226+

@unittest.skipIf(test.support.is_apple_mobile and test.support.on_github_actions,

227+

"gh-140702: Test fails regularly on iOS simulator on GitHub Actions")

226228

def test_UnixDatagramServer(self):

227229

self.run_server(socketserver.UnixDatagramServer,

228230

socketserver.DatagramRequestHandler,

229231

self.dgram_examine)

230232
231233

@requires_unix_sockets

234+

@unittest.skipIf(test.support.is_apple_mobile and test.support.on_github_actions,

235+

"gh-140702: Test fails regularly on iOS simulator on GitHub Actions")

232236

def test_ThreadingUnixDatagramServer(self):

233237

self.run_server(socketserver.ThreadingUnixDatagramServer,

234238

socketserver.DatagramRequestHandler,

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,2 @@

1+

The iOS testbed app will now expose the ``GITHUB_ACTIONS`` environment

2+

variable to iOS apps being tested.