There was an error while loading. Please reload this page.
1 parent d40692d commit a580838Copy full SHA for a580838
2 files changed
Misc/NEWS.d/next/Tools-Demos/2025-01-24-14-49-40.gh-issue-129248.JAapG2.rst
@@ -0,0 +1,2 @@
1
+The iOS test runner now strips the log prefix from each line output by the
2
+test suite.
iOS/testbed/__main__.py
@@ -2,6 +2,7 @@
import asyncio
3
import json
4
import plistlib
5
+import re
6
import shutil
7
import subprocess
8
import sys
@@ -12,6 +13,18 @@
12
13
14
DECODE_ARGS = ("UTF-8", "backslashreplace")
15
16
+# The system log prefixes each line:
17
+# 2025-01-17 16:14:29.090 Df iOSTestbed[23987:1fd393b4] (Python) ...
18
+# 2025-01-17 16:14:29.090 E iOSTestbed[23987:1fd393b4] (Python) ...
19
+
20
+LOG_PREFIX_REGEX = re.compile(
21
+ r"^\d{4}-\d{2}-\d{2}" # YYYY-MM-DD
22
+ r"\s+\d+:\d{2}:\d{2}\.\d+" # HH:MM:SS.sss
23
+ r"\s+\w+" # Df/E
24
+ r"\s+iOSTestbed\[\d+:\w+\]" # Process/thread ID
25
+ r"\s+\(Python\)\s" # Logger name
26
+)
27
28
29
# Work around a bug involving sys.exit and TaskGroups
30
# (https://github.com/python/cpython/issues/101515).
@@ -131,6 +144,8 @@ async def log_stream_task(initial_devices):
131
144
) as process:
132
145
suppress_dupes = False
133
146
while line := (await process.stdout.readline()).decode(*DECODE_ARGS):
147
+ # Strip the prefix from each log line
148
+ line = LOG_PREFIX_REGEX.sub("", line)
134
149
# The iOS log streamer can sometimes lag; when it does, it outputs
135
150
# a warning about messages being dropped... often multiple times.
136
151
# Only print the first of these duplicated warnings.
0 commit comments