aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-10-27 23:38:32 +0200
committerXavier Claessens <xclaesse@gmail.com>2021-10-28 15:32:46 -0400
commita077aaad998a70ba997822d077bc97b08e5099a7 (patch)
treec01859272ed53d5522d7bd78d9f381c28749651a
parentae35b1f45ac5850547f2db52b7b50a54789fcca1 (diff)
downloadmeson-a077aaad998a70ba997822d077bc97b08e5099a7.zip
meson-a077aaad998a70ba997822d077bc97b08e5099a7.tar.gz
meson-a077aaad998a70ba997822d077bc97b08e5099a7.tar.bz2
mtest: accept very long lines
Unless parsing TAP output, there is no strict requirement for "meson test" to process test output one line at a time; it simply looks nicer to not print a partial line if it can be avoided. However, in the case of extremely long lines StreamReader.readline can fail with a ValueError. Use readuntil('\n') instead and just process whatever pieces of the line it returns. Fixes: #8591 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/mtest.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 4f1bae0..606c891 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -1092,7 +1092,14 @@ async def read_decode(reader: asyncio.StreamReader, console_mode: ConsoleUser) -
stdo_lines = []
try:
while not reader.at_eof():
- line = decode(await reader.readline())
+ # Prefer splitting by line, as that produces nicer output
+ try:
+ line_bytes = await reader.readuntil(b'\n')
+ except asyncio.IncompleteReadError as e:
+ line_bytes = e.partial
+ except asyncio.LimitOverrunError as e:
+ line_bytes = await reader.readexactly(e.consumed)
+ line = decode(line_bytes)
stdo_lines.append(line)
if console_mode is ConsoleUser.STDOUT:
print(line, end='', flush=True)