Skip to content

Commit 18c9496

Browse files
cjihrigruyadorno
authored andcommitted
test_runner: refactor build Promise in Suite()
This commit refactors the buildSuite Promise logic in the Suite constructor to use an async function instead of creating an awkward primordial-based Promise chain. PR-URL: #55958 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 0571d55 commit 18c9496

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/internal/test_runner/test.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const {
2323
SafeMap,
2424
SafePromiseAll,
2525
SafePromiseAllReturnVoid,
26-
SafePromisePrototypeFinally,
2726
SafePromiseRace,
2827
SafeSet,
2928
StringPrototypeStartsWith,
@@ -1259,27 +1258,20 @@ class Suite extends Test {
12591258
this.skipped = false;
12601259
}
12611260

1261+
this.buildSuite = this.createBuild();
1262+
this.fn = noop;
1263+
}
1264+
1265+
async createBuild() {
12621266
try {
12631267
const { ctx, args } = this.getRunArgs();
12641268
const runArgs = [this.fn, ctx];
12651269
ArrayPrototypePushApply(runArgs, args);
1266-
this.buildSuite = SafePromisePrototypeFinally(
1267-
PromisePrototypeThen(
1268-
PromiseResolve(ReflectApply(this.runInAsyncScope, this, runArgs)),
1269-
undefined,
1270-
(err) => {
1271-
this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
1272-
}),
1273-
() => this.postBuild(),
1274-
);
1270+
await ReflectApply(this.runInAsyncScope, this, runArgs);
12751271
} catch (err) {
12761272
this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
1277-
this.postBuild();
12781273
}
1279-
this.fn = noop;
1280-
}
12811274

1282-
postBuild() {
12831275
this.buildPhaseFinished = true;
12841276
}
12851277

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy