Skip to content
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: top-level diagnostics not ommited when running with --test #46441

Merged
merged 6 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ function getRunArgs({ path, inspectPort }) {

class FileTest extends Test {
#buffer = [];
#checkNestedComment(node) {
return ArrayPrototypeIncludes(['tests', 'pass', 'fail', 'cancelled', 'skipped', 'todo', 'duration_ms'],
MoLow marked this conversation as resolved.
Show resolved Hide resolved
node.comment.split(' ')[0]);
}
#handleReportItem({ kind, node, nesting = 0 }) {
nesting += 1;

Expand Down Expand Up @@ -183,7 +187,7 @@ class FileTest extends Test {
break;

case TokenKind.COMMENT:
if (nesting === 1) {
if (nesting === 1 && this.#checkNestedComment(node)) {
// Ignore file top level diagnostics
break;
}
Expand Down
6 changes: 6 additions & 0 deletions test/message/test_runner_output.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,9 @@ test('unfinished test with unhandledRejection', async () => {
setTimeout(() => Promise.reject(new Error('bar')));
});
});

test('should not omit top-level diagnostics', () => {
MoLow marked this conversation as resolved.
Show resolved Hide resolved
setImmediate(() => {
done();
});
});
14 changes: 10 additions & 4 deletions test/message/test_runner_output.out
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,13 @@ not ok 64 - unfinished test with unhandledRejection
*
*
...
# Subtest: should not omit top-level diagnostics
ok 65 - should not omit top-level diagnostics
---
duration_ms: *
...
# Subtest: invalid subtest fail
not ok 65 - invalid subtest fail
not ok 66 - invalid subtest fail
---
duration_ms: *
failureType: 'parentAlreadyFinished'
Expand All @@ -630,15 +635,16 @@ not ok 65 - invalid subtest fail
stack: |-
*
...
1..65
1..66
# Warning: Test "unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Warning: Test "async unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Warning: Test "immediate throw - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
# tests 65
# pass 27
# Warning: Test "should not omit top-level diagnostics" generated asynchronous activity after the test ended. This activity created the error "ReferenceError: done is not defined" and would have caused the test to fail, but instead triggered an uncaughtException event.
# tests 66
# pass 28
# fail 21
# cancelled 2
# skipped 10
Expand Down
16 changes: 14 additions & 2 deletions test/message/test_runner_output_cli.out
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,13 @@ TAP version 13
*
*
...
# Subtest: should not omit top-level diagnostics
ok 65 - should not omit top-level diagnostics
---
duration_ms: *
...
# Subtest: invalid subtest fail
not ok 65 - invalid subtest fail
not ok 66 - invalid subtest fail
---
duration_ms: *
failureType: 'parentAlreadyFinished'
Expand All @@ -628,7 +633,14 @@ TAP version 13
stack: |-
*
...
1..65
1..66
# Warning: Test "unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Warning: Test "async unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Warning: Test "immediate throw - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
# Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
# Warning: Test "should not omit top-level diagnostics" generated asynchronous activity after the test ended. This activity created the error "ReferenceError: done is not defined" and would have caused the test to fail, but instead triggered an uncaughtException event.
not ok 1 - *test_runner_output.js
---
duration_ms: *
Expand Down
2 changes: 1 addition & 1 deletion test/message/test_runner_output_dot_reporter.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
..XX...X..XXX.X.....
XXX.....X..X...X....
.........X...XXX.XX.
.....XXXXXXX...XXXX
.....XXXXXXX...XXX.X
10 changes: 6 additions & 4 deletions test/message/test_runner_output_spec_reporter.out
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@

async assertion fail (*ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

true !== false

*
*
*
Expand Down Expand Up @@ -262,6 +262,7 @@
*
*

should not omit top-level diagnostics (*ms)
invalid subtest fail (*ms)
'test could not be started because its parent finished'

Expand All @@ -271,8 +272,9 @@
Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event.
Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
tests 65
pass 27
Warning: Test "should not omit top-level diagnostics" generated asynchronous activity after the test ended. This activity created the error "ReferenceError: done is not defined" and would have caused the test to fail, but instead triggered an uncaughtException event.
tests 66
pass 28
fail 21
cancelled 2
skipped 10
Expand Down