FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test_runner: call abort on test finish by rluvaton · Pull Request #48827 · nodejs/node · GitHub

/ node Public

test_runner: call abort on test finish - #48827

Merged
nodejs-github-bot merged 12 commits into
nodejs:mainfrom
rluvaton:call-abort-on-test-finish
Jul 21, 2023
Merged

test_runner: call abort on test finish#48827
nodejs-github-bot merged 12 commits into
nodejs:mainfrom
rluvaton:call-abort-on-test-finish

Conversation

Copy link
Copy Markdown
Member

nodejs-github-bot commented Jul 18, 2023
edited by MoLow
Loading

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Jul 18, 2023
rluvaton marked this pull request as ready for review July 18, 2023 14:24
Comment thread lib/internal/test_runner/test.js Outdated

benjamingr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Generally looks good, let's make sure to run benchmarks before landing because we recreate the controller each time now

MoLow previously requested changes Jul 18, 2023

MoLow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I was able to avoid recreation of the controller by testing for this.parent, wich is the case of hooks and the root test:

diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js
index cc56eec948..b81fc80bbf 100644
--- a/lib/internal/test_runner/test.js
+++ b/lib/internal/test_runner/test.js
@@ -586,13 +586,17 @@ class Test extends AsyncResource {
         return;
       }
 
-      this.#abortController.abort();
 
+      if (this.parent !== null) {
+        this.#abortController.abort();
+      }
       await afterEach();
       await after();
       this.pass();
     } catch (err) {
-      this.#abortController.abort();
+      if (this.parent !== null) {
+        this.#abortController.abort();
+      }
       try { await afterEach(); } catch { /* test is already failing, let's ignore the error */ }
       try { await after(); } catch { /* Ignore error. */ }
       if (isTestFailureError(err)) {
@@ -747,10 +751,6 @@ class Test extends AsyncResource {
     this.reporter.start(this.nesting, kFilename, this.name);
   }
 
-  recreateAbortController() {
-    this.#abortController = new AbortController();
-    this.signal = this.#abortController.signal;
-  }
 }
 
 class TestHook extends Test {
@@ -773,8 +773,6 @@ class TestHook extends Test {
     return true;
   }
   postRun() {
-    // Need to recreate the abort controller because we abort each time in the end
-    super.recreateAbortController();
   }
 }

Comment thread lib/internal/test_runner/test.js Outdated
Comment thread lib/internal/test_runner/test.js Outdated
Comment thread test/parallel/test-runner-run.mjs Outdated
MoLow dismissed their stale review July 18, 2023 15:38

requested changes addressed

MoLow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

dismissed changes request, but I would still prefer if the abort is done after hooks run

Copy link
Copy Markdown
Member

dismissed changes request, but I would still prefer if the abort is done after hooks run

@rluvaton let's do that?

Copy link
Copy Markdown
Member Author

fixed

@@ -0,0 +1,19 @@
module.exports = {
waitForAbort: function ({ testNumber, signal }) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why not await Promise.race(once(signal, 'abort'), setTimeout(1000)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Because we wait for the afterEach in the test runner...

await afterEach();
await after();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

so doing await will always fail...

Co-authored-by: Moshe Atlow <moshe@atlow.co.il>
MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 20, 2023
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 20, 2023
nodejs-github-bot merged commit 24c3d8a into nodejs:main Jul 21, 2023

Copy link
Copy Markdown
Collaborator

Landed in 24c3d8a

Copy link
Copy Markdown
Member Author

This need to be backported, right?

Copy link
Copy Markdown
Member

This need to be backported, right?

I can backport to v20 at the beginning of next week 🙂

rluvaton deleted the call-abort-on-test-finish branch July 21, 2023 13:06

aduh95 commented Jul 21, 2023

Copy link
Copy Markdown
Contributor

This shouldn't need any manual backport, or am I missing something?

Copy link
Copy Markdown
Member Author

I actually don't really know 😅

MoLow commented Jul 22, 2023

Copy link
Copy Markdown
Member

Backporting is only needed when there is a git conflict, or if tests break or some other reason like that

Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
UlisesGascon pushed a commit to UlisesGascon/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
RafaelGSS pushed a commit that referenced this pull request Aug 15, 2023
PR-URL: #48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
UlisesGascon mentioned this pull request Aug 15, 2023
targos pushed a commit that referenced this pull request Oct 28, 2023
PR-URL: #48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
PR-URL: nodejs/node#48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
PR-URL: nodejs/node#48827
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test runner executes after() in declared order

6 participants


Back | FazBrowse Home | New Git URL