diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-11-18 13:41:12 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-01-06 08:44:22 +0100 |
commit | 304abaf9ee3fd3c2cfd092811f26117d231a6a28 (patch) | |
tree | 86af0dc56d04b6a46ac53c3fd7673f160ad177d8 | |
parent | ee5e7977e3e6a24806b467010deedc71898c0aa2 (diff) | |
download | meson-304abaf9ee3fd3c2cfd092811f26117d231a6a28.zip meson-304abaf9ee3fd3c2cfd092811f26117d231a6a28.tar.gz meson-304abaf9ee3fd3c2cfd092811f26117d231a6a28.tar.bz2 |
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>
-rw-r--r-- | mesonbuild/mtest.py | 9 | ||||
-rwxr-xr-x | run_unittests.py | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index ea73a7c..8af37f0 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.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 diff --git a/run_unittests.py b/run_unittests.py index 1ff54eb..709f019 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -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) |