Skip to content

Commit cd2d2a1

Browse files
committed
test_runner: suite fixes
1 parent 1523a18 commit cd2d2a1

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

‎lib/internal/test_runner/test.js‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22
const{
3+
ArrayPrototypeMap,
34
ArrayPrototypePush,
4-
ArrayPrototypeReduce,
55
ArrayPrototypeShift,
66
ArrayPrototypeUnshift,
77
FunctionPrototype,
88
Number,
9-
PromiseResolve,
9+
PromiseAll,
1010
ReflectApply,
1111
SafeMap,
1212
}=primordials;
@@ -457,7 +457,11 @@ class Suite extends Test{
457457
constructor(options){
458458
super(options);
459459

460-
this.runInAsyncScope(this.fn);
460+
try{
461+
this.runInAsyncScope(this.fn);
462+
}catch(err){
463+
this.fail(newERR_TEST_FAILURE(err,kTestCodeFailure));
464+
}
461465
this.fn=()=>{};
462466
this.finished=true;// Forbid adding subtests to this suite
463467
}
@@ -469,11 +473,8 @@ class Suite extends Test{
469473
asyncrun(){
470474
this.parent.activeSubtests++;
471475
this.startTime=hrtime();
472-
constsubtests=this.skipped ? [] : this.subtests;
473-
awaitArrayPrototypeReduce(subtests,async(prev,subtest)=>{
474-
awaitprev;
475-
awaitsubtest.run();
476-
},PromiseResolve());
476+
constsubtests=this.skipped||this.error ? [] : this.subtests;
477+
awaitPromiseAll(ArrayPrototypeMap(subtests,(subtests)=>subtests.start()));
477478
this.pass();
478479
this.postRun();
479480
}

‎test/message/test_runner_desctibe_it.out‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ ok 19 - immediate resolve pass
182182
*
183183
*
184184
*
185+
*
186+
*
187+
*
188+
*
185189
...
186190
1..1
187191
not ok 20 - subtest sync throw fail
@@ -465,6 +469,9 @@ not ok 52 - custom inspect symbol that throws fail
465469
*
466470
*
467471
*
472+
*
473+
*
474+
*
468475
...
469476
# Subtest: sync throw fails at second
470477
not ok 2 - sync throw fails at second
@@ -480,6 +487,10 @@ not ok 52 - custom inspect symbol that throws fail
480487
*
481488
*
482489
*
490+
*
491+
*
492+
*
493+
*
483494
...
484495
1..2
485496
not ok 53 - subtest sync throw fails

0 commit comments

Comments
(0)