Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b45ad00

Browse filesBrowse files
MoLowdanielleadams
authored andcommitted
test_runner: verbous error when entire test tree is canceled
PR-URL: #44060 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 62fd899 commit b45ad00
Copy full SHA for b45ad00

File tree

Expand file treeCollapse file tree

4 files changed

+12
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+12
-10
lines changed
Open diff view settings
Collapse file

‎lib/internal/test_runner/harness.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/harness.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const {
1414
},
1515
} = require('internal/errors');
1616
const { getOptionValue } = require('internal/options');
17-
const { Test, ItTest, Suite } = require('internal/test_runner/test');
17+
const { kCancelledByParent, Test, ItTest, Suite } = require('internal/test_runner/test');
1818

1919
const isTestRunner = getOptionValue('--test');
2020
const testResources = new SafeMap();
@@ -77,7 +77,9 @@ function setup(root) {
7777
createProcessEventHandler('unhandledRejection', root);
7878

7979
const exitHandler = () => {
80-
root.postRun();
80+
root.postRun(new ERR_TEST_FAILURE(
81+
'Promise resolution is still pending but the event loop has already resolved',
82+
kCancelledByParent));
8183

8284
let passCount = 0;
8385
let failCount = 0;
Collapse file

‎lib/internal/test_runner/test.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/test.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ class Test extends AsyncResource {
511511
this.postRun();
512512
}
513513

514-
postRun() {
514+
postRun(pendingSubtestsError) {
515515
let failedSubtests = 0;
516516

517517
// If the test was failed before it even started, then the end time will
@@ -528,8 +528,8 @@ class Test extends AsyncResource {
528528
const subtest = this.subtests[i];
529529

530530
if (!subtest.finished) {
531-
subtest.cancel();
532-
subtest.postRun();
531+
subtest.cancel(pendingSubtestsError);
532+
subtest.postRun(pendingSubtestsError);
533533
}
534534

535535
if (!subtest.passed) {
@@ -691,4 +691,4 @@ class Suite extends Test {
691691
}
692692
}
693693

694-
module.exports = { kDefaultIndent, kSubtestsFailed, kTestCodeFailure, Test, Suite, ItTest };
694+
module.exports = { kCancelledByParent, kDefaultIndent, kSubtestsFailed, kTestCodeFailure, Test, Suite, ItTest };
Collapse file

‎test/message/test_runner_no_refs.out‎

Copy file name to clipboardExpand all lines: test/message/test_runner_no_refs.out
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ TAP version 13
55
---
66
duration_ms: *
77
failureType: 'cancelledByParent'
8-
error: 'test did not finish before its parent and was cancelled'
8+
error: 'Promise resolution is still pending but the event loop has already resolved'
99
code: 'ERR_TEST_FAILURE'
1010
stack: |-
1111
*
@@ -15,7 +15,7 @@ not ok 1 - does not keep event loop alive
1515
---
1616
duration_ms: *
1717
failureType: 'cancelledByParent'
18-
error: 'test did not finish before its parent and was cancelled'
18+
error: 'Promise resolution is still pending but the event loop has already resolved'
1919
code: 'ERR_TEST_FAILURE'
2020
stack: |-
2121
*
Collapse file

‎test/message/test_runner_unresolved_promise.out‎

Copy file name to clipboardExpand all lines: test/message/test_runner_unresolved_promise.out
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ not ok 2 - never resolving promise
99
---
1010
duration_ms: *
1111
failureType: 'cancelledByParent'
12-
error: 'test did not finish before its parent and was cancelled'
12+
error: 'Promise resolution is still pending but the event loop has already resolved'
1313
code: 'ERR_TEST_FAILURE'
1414
stack: |-
1515
*
@@ -19,7 +19,7 @@ not ok 3 - fail
1919
---
2020
duration_ms: 0
2121
failureType: 'cancelledByParent'
22-
error: 'test did not finish before its parent and was cancelled'
22+
error: 'Promise resolution is still pending but the event loop has already resolved'
2323
code: 'ERR_TEST_FAILURE'
2424
stack: |-
2525
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.