-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: add TAP parser #43525
test_runner: add TAP parser #43525
Conversation
3eec379
to
01e0520
Compare
01e0520
to
180d2fb
Compare
5db6310
to
4f44c29
Compare
@manekinekko is there any update on this? I think this is probably the highest priority item for the test runner at this point. |
+1. additionaly - will this solution support arbitrary |
Sorry for the delay guys. Had to deliver some work lately. So, the biggest challenge I need to work on solving right now is redesigning the lexer so it can support async scanning and make the parser support partial parsing, and emit the results once they are available (as discussed with @cjihrig over Twitter). A draft of a public API I am thinking of would look something like this: const parser = new TapParser(/* probably a flag to enable stream support */);
child.stdout.on('data', (chunk) => {
parser.parse(chunk);
});
child.stdout.on('end', () => {
const status = parser.end();
assert.strictEqual(status.ok, true);
}); @MoLow @cjihrig do you have any ideas about a different design / or a concern? |
Is the lexer right now reading individual characters? If so, I think we can leverage the fact that TAP is line based. That would make it significantly simpler than a parser for something like a programming language. I think that would also make it simpler to handle streaming. |
The parser is already splitting tokens (scanned by the lexer) into subsets, separated by EOL. The resulting array basically contains all tokens scanned at each TAP line.
So I was thinking of leveraging this logic for streams. is that was you were referring to? |
I guess I'm just wondering if we need a full blown lexer. Would it be simpler (less code, faster for us to get something shipped) to read input, turn it into lines, and parse each line. There are only a handful of line types outside of yaml blocks, and we can generally distinguish them by looking at just the first few characters of the line (whitespace, 'ok', 'not ok', 'TAP version', etc.). |
@cjihrig how would you expect a |
There is something vere similar here https://github.com/nodejs/tap2junit just FYI |
According to the spec:
and
I think if there are extra lines, that might come from |
I agree with @cjihrig on the specs. The parser in this PR will error if a line starts with an unrecognized token. Pragmas are parsed but not yet applied. Could we print those console.logs as comments? |
I think it is ok to print invalid tap as a comment or something else, but we should not just ignore it |
@cjihrig @MoLow wdyt about this API? const args = ['--test', testFixtures];
const child = spawn(process.execPath, args);
const parser = new TapParser(); //<-- create a parser instance
child.stdout.on('data', (chunk) => {
const line = chunk.toString('utf-8');
const test = parser.parseChunk(line); //<--- call parseChunk()
console.log(test);
}); The
|
@manekinekko I would expect something based on class TapParser extends readline.InterfaceConstructor {
constructor(input, output) {
super(input, output);
this.on('line', (line) => {
..parse the line and
this.emit('test') / this.emit('diagnostic') etc
})
}
} either that or class TapParser extends TapStream {
constructor(input) {
this.handle = readline.createInterface({ input });
this.handle.on('line', (line) => {
..parse the line and
this.ok(data) / this.fail(data) etc
})
}
} |
that is obviously very simplistic since TAP parsing can include multilines, etc |
097797e
to
a94927e
Compare
Landed in f8ce911 |
OMG!! That was one hell of a ride!! Thanks y'all for taking the time to review and comment on this work! Special Thank You to @cjihrig @MoLow @fhinkel @benjamingr for your help and for being such great mentors ❤️ Already looking forward to my next contributions 👍 |
cc @nodejs/testing |
Work in progress PR-URL: nodejs#43525 Refs: nodejs#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: nodejs#43525 Refs: nodejs#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: nodejs#43525 Refs: nodejs#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: nodejs#43525 Refs: nodejs#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: nodejs#43525 Refs: nodejs#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: #43525 Refs: #43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: nodejs#43525 Refs: nodejs#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: #43525 Refs: #43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: #43525 Refs: #43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: #43525 Refs: #43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: #43525 Refs: #43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: #43525 Refs: #43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
Work in progress PR-URL: nodejs/node#43525 Refs: nodejs/node#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> (cherry picked from commit f8ce9117b19702487eb600493d941f7876e00e01)
Work in progress PR-URL: nodejs/node#43525 Refs: nodejs/node#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> (cherry picked from commit f8ce9117b19702487eb600493d941f7876e00e01)
Work in progress PR-URL: nodejs/node#43525 Refs: nodejs/node#43344 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> (cherry picked from commit f8ce9117b19702487eb600493d941f7876e00e01)
This PR adds initial support for a TAP LL(1) parser. This implementation is based on the grammar for TAP14 from https://testanything.org/tap-version-14-specification.html
TODO:
make lint
)Refs: #43344
Signed-off-by: Wassim Chegham [email protected]
@benjamincburns @fhinkel @cjihrig