Skip to content

Commit 95e8c4e

Browse files
cjihrigaduh95
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 30f26ba commit 95e8c4e

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/internal/test_runner/test.js

+6-14
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)