Skip to content

Commit

Permalink
mtest: handle TAP tests with unknown version.
Browse files Browse the repository at this point in the history
TAP 14 states:
> Harnesses may treat any TAP stream lacking a version as a failed test.

TAP 13 states:
> In the absence of any version line version 12 is assumed. It is an
> error to explicitly specify any version lower than 13.

So, modern TAP is saying that we should treat a missing version as a
test definition bug, it's no longer okay to use a missing version as
saying "let's use TAP 12". But, we can choose whether to treat it that
way or error out.

Let's do a diagnostic, as we do elsewhere. But allow TAP streams that
aren't well defined, if they used to be well defined (back in TAP 12).
  • Loading branch information
eli-schwartz authored and jpakkane committed Dec 16, 2022
1 parent 27bd499 commit b7a5c38
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mesonbuild/mtest.py
Expand Up @@ -1056,7 +1056,7 @@ def complete(self) -> None:
async def parse(self, harness: 'TestHarness', lines: T.AsyncIterator[str]) -> None:
res = None
warnings = [] # type: T.List[TAPParser.UnknownLine]
version: int
version: T.Optional[int] = None

async for i in TAPParser().parse_async(lines):
if isinstance(i, TAPParser.Version):
Expand All @@ -1075,6 +1075,9 @@ async def parse(self, harness: 'TestHarness', lines: T.AsyncIterator[str]) -> No
self.additional_error += 'TAP parsing error: ' + i.message
res = TestResult.ERROR

if version is None:
self.warnings.append('Unknown TAP version. The first line MUST be `TAP version <int>`. Assuming version 12.')
version = 12
if warnings:
unknown = str(mlog.yellow('UNKNOWN'))
width = len(str(max(i.lineno for i in warnings)))
Expand Down

0 comments on commit b7a5c38

Please sign in to comment.