test_runner: call abort on test finish#48827
Conversation
|
Review requested:
|
benjamingr
left a comment
There was a problem hiding this comment.
Generally looks good, let's make sure to run benchmarks before landing because we recreate the controller each time now
MoLow
left a comment
There was a problem hiding this comment.
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();
}
}
MoLow
left a comment
There was a problem hiding this comment.
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.
why not await Promise.race(once(signal, 'abort'), setTimeout(1000)?
There was a problem hiding this comment.
Because we wait for the afterEach in the test runner...
node/lib/internal/test_runner/test.js
Lines 589 to 590 in f5f36b6
There was a problem hiding this comment.
so doing await will always fail...
Co-authored-by: Moshe Atlow <moshe@atlow.co.il>
|
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 <benjamingr@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Fix #48736 (comment)