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 bb52656

Browse filesBrowse files
authored
Revert "test_runner: run global after() hook earlier"
This reverts commit 6346bdc. Reason for revert: breaking CI PR-URL: #49110 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent e117f16 commit bb52656
Copy full SHA for bb52656

File tree

Expand file treeCollapse file tree

7 files changed

+9
-104
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+9
-104
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-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ function setup(root) {
142142
const rejectionHandler =
143143
createProcessEventHandler('unhandledRejection', root);
144144
const coverage = configureCoverage(root, globalOptions);
145-
const exitHandler = () => {
146-
root.postRun(new ERR_TEST_FAILURE(
145+
const exitHandler = async () => {
146+
await root.run(new ERR_TEST_FAILURE(
147147
'Promise resolution is still pending but the event loop has already resolved',
148148
kCancelledByParent));
149149

@@ -152,8 +152,8 @@ function setup(root) {
152152
process.removeListener('uncaughtException', exceptionHandler);
153153
};
154154

155-
const terminationHandler = () => {
156-
exitHandler();
155+
const terminationHandler = async () => {
156+
await exitHandler();
157157
process.exit();
158158
};
159159

Collapse file

‎lib/internal/test_runner/test.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/test.js
+4-23Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ class Test extends AsyncResource {
574574
}
575575
}
576576

577-
async run() {
577+
async run(pendingSubtestsError) {
578578
if (this.parent !== null) {
579579
this.parent.activeSubtests++;
580580
}
@@ -662,16 +662,9 @@ class Test extends AsyncResource {
662662
}
663663
}
664664

665-
if (this.parent !== null) {
666-
// Clean up the test. Then, try to report the results and execute any
667-
// tests that were pending due to available concurrency.
668-
//
669-
// The root test is skipped here because it is a special case. Its
670-
// postRun() method is called when the process is getting ready to exit.
671-
// This helps catch any asynchronous activity that occurs after the tests
672-
// have finished executing.
673-
this.postRun();
674-
}
665+
// Clean up the test. Then, try to report the results and execute any
666+
// tests that were pending due to available concurrency.
667+
this.postRun(pendingSubtestsError);
675668
}
676669

677670
postRun(pendingSubtestsError) {
@@ -713,18 +706,6 @@ class Test extends AsyncResource {
713706
this.parent.addReadySubtest(this);
714707
this.parent.processReadySubtestRange(false);
715708
this.parent.processPendingSubtests();
716-
717-
if (this.parent === this.root &&
718-
this.root.activeSubtests === 0 &&
719-
this.root.pendingSubtests.length === 0 &&
720-
this.root.readySubtests.size === 0 &&
721-
this.root.hooks.after.length > 0) {
722-
// This is done so that any global after() hooks are run. At this point
723-
// all of the tests have finished running. However, there might be
724-
// ref'ed handles keeping the event loop alive. This gives the global
725-
// after() hook a chance to clean them up.
726-
this.root.run();
727-
}
728709
} else if (!this.reported) {
729710
const {
730711
diagnostics,
Collapse file

‎test/fixtures/test-runner/output/async-test-scheduling.mjs‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/async-test-scheduling.mjs
-13Lines changed: 0 additions & 13 deletions
This file was deleted.
Collapse file

‎test/fixtures/test-runner/output/async-test-scheduling.snapshot‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/async-test-scheduling.snapshot
-37Lines changed: 0 additions & 37 deletions
This file was deleted.
Collapse file

‎test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ not ok 2 - /test/fixtures/test-runner/output/global_after_should_fail_the_test.j
2222
*
2323
*
2424
*
25+
*
2526
...
2627
1..1
2728
# tests 1
Collapse file

‎test/parallel/test-runner-output.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-output.mjs
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const tests = [
7474
{ name: 'test-runner/output/unresolved_promise.js' },
7575
{ name: 'test-runner/output/default_output.js', transform: specTransform, tty: true },
7676
{ name: 'test-runner/output/arbitrary-output.js' },
77-
{ name: 'test-runner/output/async-test-scheduling.mjs' },
7877
!skipForceColors ? {
7978
name: 'test-runner/output/arbitrary-output-colored.js',
8079
transform: snapshot.transform(specTransform, replaceTestDuration), tty: true
Collapse file

‎test/parallel/test-runner-root-after-with-refed-handles.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-root-after-with-refed-handles.js
-26Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

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