mtest: remove unused arguments from read_decode_lines()

The only time the argument would matter (console_mode ==
ConsoleUser.STDOUT) never happens as the only time the function is
ever called is when parsing of the output is needed which in turns
implies that console_mode != ConsoleUser.STDOUT.
pull/9478/head
Hemmo Nieminen 3 years ago committed by Eli Schwartz
parent cb0cbb3e5e
commit d6e1b72db0
  1. 12
      mesonbuild/mtest.py

@ -1120,15 +1120,13 @@ async def read_decode(reader: asyncio.StreamReader, console_mode: ConsoleUser) -
# Extract lines out of the StreamReader. Print them # Extract lines out of the StreamReader. Print them
# along the way if requested, and at the end collect # along the way if requested, and at the end collect
# them all into a future. # them all into a future.
async def read_decode_lines(reader: asyncio.StreamReader, q: 'asyncio.Queue[T.Optional[str]]', async def read_decode_lines(reader: asyncio.StreamReader,
console_mode: ConsoleUser) -> str: q: 'asyncio.Queue[T.Optional[str]]') -> str:
stdo_lines = [] stdo_lines = []
try: try:
while not reader.at_eof(): while not reader.at_eof():
line = decode(await reader.readline()) line = decode(await reader.readline())
stdo_lines.append(line) stdo_lines.append(line)
if console_mode is ConsoleUser.STDOUT:
print(line, end='', flush=True)
await q.put(line) await q.put(line)
return ''.join(stdo_lines) return ''.join(stdo_lines)
except asyncio.CancelledError: except asyncio.CancelledError:
@ -1217,9 +1215,9 @@ class TestSubprocess:
self.postwait_fn = postwait_fn # type: T.Callable[[], None] self.postwait_fn = postwait_fn # type: T.Callable[[], None]
self.all_futures = [] # type: T.List[asyncio.Future] self.all_futures = [] # type: T.List[asyncio.Future]
def stdout_lines(self, console_mode: ConsoleUser) -> T.AsyncIterator[str]: def stdout_lines(self) -> T.AsyncIterator[str]:
q = asyncio.Queue() # type: asyncio.Queue[T.Optional[str]] q = asyncio.Queue() # type: asyncio.Queue[T.Optional[str]]
decode_coro = read_decode_lines(self._process.stdout, q, console_mode) decode_coro = read_decode_lines(self._process.stdout, q)
self.stdo_task = asyncio.ensure_future(decode_coro) self.stdo_task = asyncio.ensure_future(decode_coro)
return queue_iter(q) return queue_iter(q)
@ -1464,7 +1462,7 @@ class SingleTestRunner:
parse_task = None parse_task = None
if self.runobj.needs_parsing: if self.runobj.needs_parsing:
parse_coro = self.runobj.parse(harness, p.stdout_lines(self.console_mode)) parse_coro = self.runobj.parse(harness, p.stdout_lines())
parse_task = asyncio.ensure_future(parse_coro) parse_task = asyncio.ensure_future(parse_coro)
stdo_task, stde_task = p.communicate(self.console_mode) stdo_task, stde_task = p.communicate(self.console_mode)

Loading…
Cancel
Save