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>
pull/9667/head
Paolo Bonzini 3 years ago committed by Nirbheek Chauhan
parent 52c28eb962
commit c9adc06699
  1. 9
      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)

Loading…
Cancel
Save