test_runner: fix spec skip detection#47537
Conversation
|
Review requested:
|
|
@nodejs/test_runner even after this PR there are discrepancies when running with and without |
|
CC @ErickWendel |
| hasChildren = true; | ||
| } | ||
| const skippedSubtest = subtest && data.skip && data.skip !== undefined; | ||
| const skippedSubtest = subtest && 'skip' in data; |
There was a problem hiding this comment.
i don't think this is right - skip has to be truthy, otherwise skip: false will skip a test.
There was a problem hiding this comment.
skip can be an empty string or undefined, but Il fix it to support false
There was a problem hiding this comment.
in every test runner i'm aware of, a falsyskip - including undefined and an empty string - does not skip the test. The purpose is so you can dynamically skip something, and it would be incredibly surprising and confusing to users if a falsy value meant "true".
There was a problem hiding this comment.
yeah I guess you are right it seems like the TAP parser makes skip an empty string
4971d18 to
e7e9868
Compare
| test.reason = reason; | ||
| } | ||
|
|
||
| if (todoOrSkipToken === 'todo' || todoOrSkipToken === 'skip') { |
There was a problem hiding this comment.
Nothing that needs to change in this PR, but this whole block (lines 745-761 with the changes in this PR) looks like it could be optimized a bit.
| id: '2', | ||
| description: 'test', | ||
| reason: '', | ||
| reason: true, |
There was a problem hiding this comment.
The changes in this file, and the first two changes in test/parallel/test-runner-tap-parser.js don't look correct. I would think the boolean would be status.skip, which it looks like it is on line 321. The reason should be a string.
| directive = this.reporter.getSkip(node.reason || true); | ||
| } else if (todo) { | ||
| directive = this.reporter.getTodo(node.reason); | ||
| directive = this.reporter.getTodo(node.reason || true); |
There was a problem hiding this comment.
inside this code branch? yes
There was a problem hiding this comment.
then why the node.reason || at all, if it'll literally always be true? or is it for a skip message
There was a problem hiding this comment.
It is a string including a description for the skip, it is not necesaraly a boolean
There was a problem hiding this comment.
So in lib/internal/test_runner/tests_stream.js we are doing this. Should we change that to || instead of using || in this file and then ?? again there?
There was a problem hiding this comment.
no, since in tests_stream we do not want to convert falsy values to true, but here it is ok since we are inside an if detecting we are in a skipped test
cjihrig
left a comment
There was a problem hiding this comment.
LGTM, but left a small comment: #47537 (comment).
|
Landed in 46a3cff |
PR-URL: #47537 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: #47537 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#47537 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Refs: #47525 (comment)