summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2024-12-09 05:28:57 (GMT)
committerGitHub <noreply@github.com>2024-12-09 05:28:57 (GMT)
commit2041a95e68ebf6d13f867e214ada28affa830669 (patch)
treeca4fbf70b3557908e77de8ea2b66e99847145dda /Doc
parentd8d12b37b5e5acb354db84b07dab8de64a6b9475 (diff)
downloadcpython-2041a95e68ebf6d13f867e214ada28affa830669.zip
cpython-2041a95e68ebf6d13f867e214ada28affa830669.tar.gz
cpython-2041a95e68ebf6d13f867e214ada28affa830669.tar.bz2
gh-126925: Modify how iOS test results are gathered (#127592)
Adds a `use_system_log` config item to enable stdout/stderr redirection for Apple platforms. This log streaming is then used by a new iOS test runner script, allowing the display of test suite output at runtime. The iOS test runner script can be used by any Python project, not just the CPython test suite.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/init_config.rst9
-rw-r--r--Doc/using/ios.rst53
-rw-r--r--Doc/whatsnew/3.14.rst7
3 files changed, 65 insertions, 4 deletions
diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index d6569dd..7497bf2 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -1281,6 +1281,15 @@ PyConfig
Default: ``1`` in Python config and ``0`` in isolated config.
+ .. c:member:: int use_system_logger
+
+ If non-zero, ``stdout`` and ``stderr`` will be redirected to the system
+ log.
+
+ Only available on macOS 10.12 and later, and on iOS.
+
+ Default: ``0`` (don't use system log).
+
.. c:member:: int user_site_directory
If non-zero, add the user site directory to :data:`sys.path`.
diff --git a/Doc/using/ios.rst b/Doc/using/ios.rst
index 4d4eb20..aa43f75 100644
--- a/Doc/using/ios.rst
+++ b/Doc/using/ios.rst
@@ -292,10 +292,12 @@ To add Python to an iOS Xcode project:
10. Add Objective C code to initialize and use a Python interpreter in embedded
mode. You should ensure that:
- * :c:member:`UTF-8 mode <PyPreConfig.utf8_mode>` is *enabled*;
- * :c:member:`Buffered stdio <PyConfig.buffered_stdio>` is *disabled*;
- * :c:member:`Writing bytecode <PyConfig.write_bytecode>` is *disabled*;
- * :c:member:`Signal handlers <PyConfig.install_signal_handlers>` are *enabled*;
+ * UTF-8 mode (:c:member:`PyPreConfig.utf8_mode`) is *enabled*;
+ * Buffered stdio (:c:member:`PyConfig.buffered_stdio`) is *disabled*;
+ * Writing bytecode (:c:member:`PyConfig.write_bytecode`) is *disabled*;
+ * Signal handlers (:c:member:`PyConfig.install_signal_handlers`) are *enabled*;
+ * System logging (:c:member:`PyConfig.use_system_logger`) is *enabled*
+ (optional, but strongly recommended);
* ``PYTHONHOME`` for the interpreter is configured to point at the
``python`` subfolder of your app's bundle; and
* The ``PYTHONPATH`` for the interpreter includes:
@@ -324,6 +326,49 @@ modules in your app, some additional steps will be required:
* If you're using a separate folder for third-party packages, ensure that folder
is included as part of the ``PYTHONPATH`` configuration in step 10.
+Testing a Python package
+------------------------
+
+The CPython source tree contains :source:`a testbed project <iOS/testbed>` that
+is used to run the CPython test suite on the iOS simulator. This testbed can also
+be used as a testbed project for running your Python library's test suite on iOS.
+
+After building or obtaining an iOS XCFramework (See :source:`iOS/README.rst`
+for details), create a clone of the Python iOS testbed project by running:
+
+.. code-block:: bash
+
+ $ python iOS/testbed clone --framework <path/to/Python.xcframework> --app <path/to/module1> --app <path/to/module2> app-testbed
+
+You will need to modify the ``iOS/testbed`` reference to point to that
+directory in the CPython source tree; any folders specified with the ``--app``
+flag will be copied into the cloned testbed project. The resulting testbed will
+be created in the ``app-testbed`` folder. In this example, the ``module1`` and
+``module2`` would be importable modules at runtime. If your project has
+additional dependencies, they can be installed into the
+``app-testbed/iOSTestbed/app_packages`` folder (using ``pip install --target
+app-testbed/iOSTestbed/app_packages`` or similar).
+
+You can then use the ``app-testbed`` folder to run the test suite for your app,
+For example, if ``module1.tests`` was the entry point to your test suite, you
+could run:
+
+.. code-block:: bash
+
+ $ python app-testbed run -- module1.tests
+
+This is the equivalent of running ``python -m module1.tests`` on a desktop
+Python build. Any arguments after the ``--`` will be passed to the testbed as
+if they were arguments to ``python -m`` on a desktop machine.
+
+You can also open the testbed project in Xcode by running:
+
+.. code-block:: bash
+
+ $ open app-testbed/iOSTestbed.xcodeproj
+
+This will allow you to use the full Xcode suite of tools for debugging.
+
App Store Compliance
====================
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index b300e34..b71d31f 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -245,6 +245,13 @@ Other language changes
making it a :term:`generic type`.
(Contributed by Brian Schubert in :gh:`126012`.)
+* iOS and macOS apps can now be configured to redirect ``stdout`` and
+ ``stderr`` content to the system log. (Contributed by Russell Keith-Magee in
+ :gh:`127592`.)
+
+* The iOS testbed is now able to stream test output while the test is running.
+ The testbed can also be used to run the test suite of projects other than
+ CPython itself. (Contributed by Russell Keith-Magee in :gh:`127592`.)
New modules
===========