https://github.com/python/cpython/commit/a58083811a51764c47fbb7cbd67e87e1124d53e8
commit: a58083811a51764c47fbb7cbd67e87e1124d53e8
branch: main
author: Russell Keith-Magee <[email protected]>
committer: freakboy3742 <[email protected]>
date: 2025-01-25T16:49:39+08:00
summary:
gh-129248: Filter out the iOS log prefix from testbed runner output. (#129252)
Filter out the iOS log prefix from testbed runner output.
files:
A Misc/NEWS.d/next/Tools-Demos/2025-01-24-14-49-40.gh-issue-129248.JAapG2.rst
M iOS/testbed/__main__.py
diff --git
a/Misc/NEWS.d/next/Tools-Demos/2025-01-24-14-49-40.gh-issue-129248.JAapG2.rst
b/Misc/NEWS.d/next/Tools-Demos/2025-01-24-14-49-40.gh-issue-129248.JAapG2.rst
new file mode 100644
index 00000000000000..e3c781cf10cf50
--- /dev/null
+++
b/Misc/NEWS.d/next/Tools-Demos/2025-01-24-14-49-40.gh-issue-129248.JAapG2.rst
@@ -0,0 +1,2 @@
+The iOS test runner now strips the log prefix from each line output by the
+test suite.
diff --git a/iOS/testbed/__main__.py b/iOS/testbed/__main__.py
index 068272835a5b95..b4499f5ac171a8 100644
--- a/iOS/testbed/__main__.py
+++ b/iOS/testbed/__main__.py
@@ -2,6 +2,7 @@
import asyncio
import json
import plistlib
+import re
import shutil
import subprocess
import sys
@@ -12,6 +13,18 @@
DECODE_ARGS = ("UTF-8", "backslashreplace")
+# The system log prefixes each line:
+# 2025-01-17 16:14:29.090 Df iOSTestbed[23987:1fd393b4] (Python) ...
+# 2025-01-17 16:14:29.090 E iOSTestbed[23987:1fd393b4] (Python) ...
+
+LOG_PREFIX_REGEX = re.compile(
+ r"^\d{4}-\d{2}-\d{2}" # YYYY-MM-DD
+ r"\s+\d+:\d{2}:\d{2}\.\d+" # HH:MM:SS.sss
+ r"\s+\w+" # Df/E
+ r"\s+iOSTestbed\[\d+:\w+\]" # Process/thread ID
+ r"\s+\(Python\)\s" # Logger name
+)
+
# Work around a bug involving sys.exit and TaskGroups
# (https://github.com/python/cpython/issues/101515).
@@ -131,6 +144,8 @@ async def log_stream_task(initial_devices):
) as process:
suppress_dupes = False
while line := (await process.stdout.readline()).decode(*DECODE_ARGS):
+ # Strip the prefix from each log line
+ line = LOG_PREFIX_REGEX.sub("", line)
# The iOS log streamer can sometimes lag; when it does, it outputs
# a warning about messages being dropped... often multiple times.
# Only print the first of these duplicated warnings.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]