mirror of https://github.com/nodejs/node.git
test_runner: refactor Promise chain in run()
This commit refactors the chain of functions in run() to use an async function instead of creating an awkward primordial-based Promise chain. PR-URL: https://github.com/nodejs/node/pull/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>pull/55988/head
parent
216fd206b6
commit
3c35188639
|
@ -17,7 +17,6 @@ const {
|
|||
ArrayPrototypeSort,
|
||||
ObjectAssign,
|
||||
PromisePrototypeThen,
|
||||
PromiseResolve,
|
||||
PromiseWithResolvers,
|
||||
SafeMap,
|
||||
SafePromiseAll,
|
||||
|
@ -801,9 +800,17 @@ function run(options = kEmptyObject) {
|
|||
}
|
||||
}
|
||||
|
||||
const setupPromise = PromiseResolve(setup?.(root.reporter));
|
||||
PromisePrototypeThen(PromisePrototypeThen(PromisePrototypeThen(setupPromise, runFiles), postRun), teardown);
|
||||
const runChain = async () => {
|
||||
if (typeof setup === 'function') {
|
||||
await setup(root.reporter);
|
||||
}
|
||||
|
||||
await runFiles();
|
||||
postRun?.();
|
||||
teardown?.();
|
||||
};
|
||||
|
||||
runChain();
|
||||
return root.reporter;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue