mtest: remove argument to the TAPParser constructor

Pass the StringIO object to the parse method instead, because
there will be no T.Iterator[str] to use in the asynchronous
case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/8029/head
Paolo Bonzini 4 years ago
parent ee5e7977e3
commit 304abaf9ee
  1. 9
      mesonbuild/mtest.py
  2. 4
      run_unittests.py

@ -237,9 +237,6 @@ class TAPParser:
state = _MAIN
version = 12
def __init__(self, io: T.Iterator[str]):
self.io = io
def parse_test(self, ok: bool, num: int, name: str, directive: T.Optional[str], explanation: T.Optional[str]) -> \
T.Generator[T.Union['TAPParser.Test', 'TAPParser.Error'], None, None]:
name = name.strip()
@ -258,8 +255,8 @@ class TAPParser:
yield self.Test(num, name, TestResult.OK if ok else TestResult.FAIL, explanation)
def parse(self) -> T.Iterator[TYPE_TAPResult]:
for line in self.io:
def parse(self, io: T.Iterator[str]) -> T.Iterator[TYPE_TAPResult]:
for line in io:
yield from self.parse_line(line)
yield from self.parse_line(None)
@ -747,7 +744,7 @@ class TestRun:
results = {} # type: T.Dict[str, TestResult]
failed = False
for n, i in enumerate(TAPParser(io.StringIO(stdo)).parse()):
for n, i in enumerate(TAPParser().parse(io.StringIO(stdo))):
if isinstance(i, TAPParser.Bailout):
results[str(n)] = TestResult.ERROR
failed = True

@ -8875,8 +8875,8 @@ class TAPParserTests(unittest.TestCase):
next(events)
def parse_tap(self, s):
parser = TAPParser(io.StringIO(s))
return iter(parser.parse())
parser = TAPParser()
return iter(parser.parse(io.StringIO(s)))
def parse_tap_v13(self, s):
events = self.parse_tap('TAP version 13\n' + s)

Loading…
Cancel
Save