Skip to content

Commit

Permalink
test_runner: suite fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Jul 10, 2022
1 parent 3350d96 commit 35602f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
const {
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeReduce,
ArrayPrototypeShift,
ArrayPrototypeUnshift,
FunctionPrototype,
Number,
PromiseResolve,
PromiseAll,
ReflectApply,
SafeMap,
} = primordials;
Expand Down Expand Up @@ -457,7 +457,11 @@ class Suite extends Test {
constructor(options) {
super(options);

this.runInAsyncScope(this.fn);
try {
this.runInAsyncScope(this.fn);
} catch (err) {
this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
}
this.fn = () => {};
this.finished = true; // Forbid adding subtests to this suite
}
Expand All @@ -469,11 +473,8 @@ class Suite extends Test {
async run() {
this.parent.activeSubtests++;
this.startTime = hrtime();
const subtests = this.skipped ? [] : this.subtests;
await ArrayPrototypeReduce(subtests, async (prev, subtest) => {
await prev;
await subtest.run();
}, PromiseResolve());
const subtests = this.skipped || this.error ? [] : this.subtests;
await PromiseAll(ArrayPrototypeMap(subtests, (subtests) => subtests.start()));
this.pass();
this.postRun();
}
Expand Down
11 changes: 11 additions & 0 deletions test/message/test_runner_desctibe_it.out
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ ok 19 - immediate resolve pass
*
*
*
*
*
*
*
...
1..1
not ok 20 - subtest sync throw fail
Expand Down Expand Up @@ -465,6 +469,9 @@ not ok 52 - custom inspect symbol that throws fail
*
*
*
*
*
*
...
# Subtest: sync throw fails at second
not ok 2 - sync throw fails at second
Expand All @@ -480,6 +487,10 @@ not ok 52 - custom inspect symbol that throws fail
*
*
*
*
*
*
*
...
1..2
not ok 53 - subtest sync throw fails
Expand Down

0 comments on commit 35602f9

Please sign in to comment.