Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-126925: Modify how iOS test results are gathered #127592

Merged
merged 12 commits into from
Dec 9, 2024

Conversation

freakboy3742
Copy link
Contributor

@freakboy3742 freakboy3742 commented Dec 4, 2024

Xcode 16 deprecated the xcresultool tool we were using to gather test results after an iOS test run.

This tool was less than ideal anyway, as it didn't provide a way to see test results as the test suite was running. As a result, we had intermittent CI test failures that manifested as "test suite didn't finish", with no runtime debugging possible.

This PR adds a new configuration item (config->use_system_logger) for Apple platforms, providing the option to redirect stdout and stderr to the system log. This mirrors how Android operates - the implementation is strongly influenced by the Android implementation, but is just different enough that refactoring into a common base class is more trouble than it's worth IMHO.

This PR also adds a new test runner for iOS projects. This test runner uses the iOS testbed as a template, installing the compiled framework into copy generated from the template; and then building and running the test project in parallel with a log streamer that captures the system log from the iOS simulator as it runs. This allows us to observe test output as the test suite runs.

The test runner also includes options to allows the installation of app code. This means the testbed project can be used to test arbitrary Python code, in addition to the core CPython test suite.

Although this feature is primarily useful for iOS apps, the same code can be used for macOS apps - something that is useful when embedding Python in to a GUI app (where stdout/stderr isn't visible).

This PR resolves both #126925 and #126821; Resolving #126821 was a pre-requisite for fixing #126925 (and is the first commit in this PR), but by itself, there's very little opportunity to evaluate that it's working. You need an updated test runner to be able to observe that stdout/err redirection is working.

Fixes #126925
Fixes #126821


📚 Documentation preview 📚: https://cpython-previews--127592.org.readthedocs.build/

@freakboy3742 freakboy3742 added tests Tests in the Lib/test dir OS-mac stdlib Python modules in the Lib dir 3.13 bugs and security fixes OS-ios 3.14 new features, bugs and security fixes needs backport to 3.13 bugs and security fixes labels Dec 4, 2024
@freakboy3742
Copy link
Contributor Author

!buildbot iOS

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 60584e0 🤖

The command will test the builders whose names match following regular expression: iOS

The builders matched are:

  • iOS ARM64 Simulator PR

@freakboy3742
Copy link
Contributor Author

Moving to draft because of the test failures on macOS buils

@freakboy3742 freakboy3742 marked this pull request as draft December 4, 2024 07:34
@freakboy3742
Copy link
Contributor Author

!buildbot iOS

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 89bb435 🤖

The command will test the builders whose names match following regular expression: iOS

The builders matched are:

  • iOS ARM64 Simulator PR

@freakboy3742 freakboy3742 marked this pull request as ready for review December 5, 2024 06:38
@freakboy3742
Copy link
Contributor Author

I've now resolved the testing issue; I've also added some documentation for the new capabilities.

@freakboy3742
Copy link
Contributor Author

First, it would be better to condense the string of 30+ Messages dropped log entries to just one as the action to be taken is the same regardless of how many there are:

Agreed - this is a case where it's the iOS logger being messy, and this script is just returning the mess verbatim. However, it's something we might be able to clean up by checking for that specific content, and swallowing all but the first occurrence.

And a stray Android reference remains in a test_apple.py comment.
...
You might want to consider adding a What's New entry as well.

Ack - I'll add both these two.

@freakboy3742
Copy link
Contributor Author

!buildbot iOS

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 47870c4 🤖

The command will test the builders whose names match following regular expression: iOS

The builders matched are:

  • iOS ARM64 Simulator PR

@freakboy3742
Copy link
Contributor Author

I did not make a thorough review especially of the details of how the logging would be configured for a Mac app.

There's no command line interface; it's currently only exposed as an option for embedded-mode apps. Briefcase's stub binary, for example, would be able to add stdout redirection as part of the app startup sequence, rather than requiring the std-nslog package to install a logging shim at runtime.

@ned-deily I've now made those changes, including surpassing all but the first occurrence of the "Messages dropped..." messages in any block when they occur. Did you want to review this again, or are you OK with me to merge and backport the changes?

@ned-deily
Copy link
Member

LGTM, thanks

@freakboy3742 freakboy3742 merged commit 2041a95 into python:main Dec 9, 2024
42 checks passed
@miss-islington-app
Copy link

Thanks @freakboy3742 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @freakboy3742, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 2041a95e68ebf6d13f867e214ada28affa830669 3.13

@freakboy3742 freakboy3742 deleted the ios-testbed-wrapper branch December 9, 2024 05:29
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 9, 2024
…honGH-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.
(cherry picked from commit 2041a95)

Co-authored-by: Russell Keith-Magee <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Dec 9, 2024

GH-127754 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 9, 2024
freakboy3742 added a commit that referenced this pull request Dec 9, 2024
#127754)

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.
(cherry picked from commit 2041a95)
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 13, 2024
…onGH-127592) (python#127754)

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.
(cherry picked from commit 2041a95)
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 13, 2024
…honGH-127592) (python#127754)

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.
(cherry picked from commit 2041a95)
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 13, 2024
…honGH-127592) (python#127754)

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.
(cherry picked from commit 2041a95)
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 13, 2024
…honGH-127592) (python#127754)

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.
(cherry picked from commit 2041a95)
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 13, 2024
)

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.
freakboy3742 added a commit to freakboy3742/cpython that referenced this pull request Dec 13, 2024
…honGH-127592) (python#127754)

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.
(cherry picked from commit 2041a95)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes OS-ios OS-mac stdlib Python modules in the Lib dir tests Tests in the Lib/test dir
Projects
None yet
3 participants