Skip to content

Commit 06085bd

Browse files
committed
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.
1 parent 3178a76 commit 06085bd

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
@@ -24,7 +24,6 @@ const {
2424
SafeMap,
2525
SafePromiseAll,
2626
SafePromiseAllReturnVoid,
27-
SafePromisePrototypeFinally,
2827
SafePromiseRace,
2928
SafeSet,
3029
StringPrototypeStartsWith,
@@ -1258,27 +1257,20 @@ class Suite extends Test {
12581257
this.skipped = false;
12591258
}
12601259

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

1281-
postBuild() {
12821274
this.buildPhaseFinished = true;
12831275
}
12841276

0 commit comments

Comments
 (0)