-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: call abort on test finish #48827
test_runner: call abort on test finish #48827
Conversation
Review requested:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, let's make sure to run benchmarks before landing because we recreate the controller each time now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dismissed changes request, but I would still prefer if the abort is done after hooks run
@rluvaton let's do that? |
fixed |
@@ -0,0 +1,19 @@ | |||
module.exports = { | |||
waitForAbort: function ({ testNumber, signal }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not await Promise.race(once(signal, 'abort'), setTimeout(1000)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we wait for the afterEach
in the test runner...
node/lib/internal/test_runner/test.js
Lines 589 to 590 in f5f36b6
await afterEach(); | |
await after(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so doing await will always fail...
Co-authored-by: Moshe Atlow <[email protected]>
Landed in 24c3d8a |
This need to be backported, right? |
I can backport to v20 at the beginning of next week 🙂 |
This shouldn't need any manual backport, or am I missing something? |
I actually don't really know 😅 |
Backporting is only needed when there is a git conflict, or if tests break or some other reason like that |
PR-URL: nodejs#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: #48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: #48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs/node#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
PR-URL: nodejs/node#48827 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fix #48736 (comment)