-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Tap parser fails if a test logs a number #46048
Comments
cc @manekinekko |
While testing my PR, I observed something unexpected,
it throws error, saying but when I am running code
then it pass, but doesn't print the expected output and with code
it passed as expected. what I found, this happening because of logic written inside your views @cjihrig @manekinekko |
@pulkit-30 writing to stdout has the potential to interfere with TAP parsing because TAP also uses stdout. I believe that's what is happening here. I don't think we can really avoid that aspect, but the parser should be able to handle these cases without crashing. |
It would be very nice if output during tests could be redirected as e.g. TAP comments. I'm off and on working on building a node:test extension for VS Code and ended up implementing that by hand in a wrapper script |
I'm not sure what version(s) you're testing on, but that is the behavior since #43525. This issue is just one of a handful of bugs in the parser. |
Ah, got it. That only happens when running |
The parser throws on invalid syntax by design. We can however catch those exceptions (in the runner) and decide whether we silence them or how to handle invalid syntax. @cjihrig @MoLow any suggestions? |
I don't think that is the correct behavior, based on this text from the spec:
Right now, it looks like we are treating it as a failure. We're also surfacing an error message ( We're also losing valid data from that file. Given the following file, I would expect test 1 and test 3 at least to pass. const test = require('node:test');
test('test 1');
test('test 2', () => {
console.log('1234');
});
test('test 3'); In my opinion we should ignore invalid TAP, but continue parsing. EDIT: By ignore invalid TAP, I really mean display it as a diagnostic and ignore it from a parsing perspective. |
PR-URL: nodejs/node#46056 Fixes: nodejs/node#46048 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> (cherry picked from commit 4c08c20e575a0954fe3977a20e9f52b4980a2e48)
PR-URL: nodejs/node#46056 Fixes: nodejs/node#46048 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> (cherry picked from commit 4c08c20e575a0954fe3977a20e9f52b4980a2e48)
PR-URL: nodejs#46056 Fixes: nodejs#46048 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: nodejs#46056 Fixes: nodejs#46048 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: nodejs#46056 Fixes: nodejs#46048 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: nodejs#46056 Fixes: nodejs#46048 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Version
v19.3.0
Platform
Linux Helios 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
test_runner
What steps will reproduce the bug?
Have a test file containing
How often does it reproduce? Is there a required condition?
100% reproduction
What is the expected behavior?
The test passes when running
node --test
What do you see instead?
Additional information
This happens for any numberic value, so
console.log('1234')
will produce the same resultThe text was updated successfully, but these errors were encountered: