Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Jun 14, 2022
1 parent 4bca978 commit 6ae4e74
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
9 changes: 8 additions & 1 deletion lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Test extends AsyncResource {
processReadySubtestRange(canSend) {
const start = this.waitingOn;
const end = start + this.readySubtests.size;
let shouldReportSubtest = this.parent !== null;

for (let i = start; i < end; i++) {
const subtest = this.readySubtests.get(i);
Expand All @@ -183,6 +184,11 @@ class Test extends AsyncResource {
return;
}

if (shouldReportSubtest) {
this.reporter.subTest(this.indent, this.name);
shouldReportSubtest = false;
}

// Report the subtest's results and remove it from the ready map.
subtest.finalize();
this.readySubtests.delete(i);
Expand Down Expand Up @@ -295,7 +301,6 @@ class Test extends AsyncResource {
}

async run() {
this.reporter.subTest(this.indent, this.name);
this.parent.activeSubtests++;
this.startTime = hrtime();

Expand Down Expand Up @@ -417,6 +422,8 @@ class Test extends AsyncResource {
// Output this test's results and update the parent's waiting counter.
if (this.subtests.length > 0) {
this.reporter.plan(this.subtests[0].indent, this.subtests.length);
} else {
this.reporter.subTest(this.indent, this.name);
}

this.report();
Expand Down
35 changes: 18 additions & 17 deletions test/message/test_runner_output.out
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,22 @@ not ok 22 - sync throw non-error fail
...
# Subtest: level 0a
# Subtest: level 1a
# Subtest: level 1b
# Subtest: level 1c
# Subtest: level 1d
ok 1 - level 1a
---
duration_ms: *
...
# Subtest: level 1b
ok 2 - level 1b
---
duration_ms: *
...
# Subtest: level 0a
# Subtest: level 1c
ok 3 - level 1c
---
duration_ms: *
...
# Subtest: level 1d
ok 4 - level 1d
---
duration_ms: *
Expand All @@ -255,15 +256,15 @@ ok 23 - level 0a
...
# Subtest: top level
# Subtest: +long running
# Subtest: +short running
# Subtest: ++short running
not ok 1 - +long running
---
duration_ms: *
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
code: 'ERR_TEST_FAILURE'
...
# Subtest: +short running
# Subtest: ++short running
ok 1 - ++short running
---
duration_ms: *
Expand Down Expand Up @@ -455,18 +456,6 @@ not ok 50 - callback called twice in future tick
*
...
# Subtest: callback async throw
# Subtest: callback async throw after done
# Subtest: only is set but not in only mode
# Subtest: running subtest 1
# Subtest: running subtest 2
# Subtest: running subtest 3
# Subtest: running subtest 4
# Subtest: custom inspect symbol fail
# Subtest: custom inspect symbol that throws fail
# Subtest: subtest sync throw fails
# Subtest: sync throw fails at first
# Subtest: sync throw fails at second
# Subtest: invalid subtest fail
not ok 51 - callback async throw
---
duration_ms: *
Expand All @@ -476,22 +465,28 @@ not ok 51 - callback async throw
stack: |-
*
...
# Subtest: callback async throw after done
ok 52 - callback async throw after done
---
duration_ms: *
...
# Subtest: only is set but not in only mode
# Subtest: running subtest 1
ok 1 - running subtest 1
---
duration_ms: *
...
# Subtest: running subtest 2
ok 2 - running subtest 2
---
duration_ms: *
...
# Subtest: running subtest 3
ok 3 - running subtest 3
---
duration_ms: *
...
# Subtest: running subtest 4
ok 4 - running subtest 4
---
duration_ms: *
Expand All @@ -501,13 +496,15 @@ ok 53 - only is set but not in only mode
---
duration_ms: *
...
# Subtest: custom inspect symbol fail
not ok 54 - custom inspect symbol fail
---
duration_ms: *
failureType: 'testCodeFailure'
error: 'customized'
code: 'ERR_TEST_FAILURE'
...
# Subtest: custom inspect symbol that throws fail
not ok 55 - custom inspect symbol that throws fail
---
duration_ms: *
Expand All @@ -519,6 +516,8 @@ not ok 55 - custom inspect symbol that throws fail
}
code: 'ERR_TEST_FAILURE'
...
# Subtest: subtest sync throw fails
# Subtest: sync throw fails at first
not ok 1 - sync throw fails at first
---
duration_ms: *
Expand All @@ -537,6 +536,7 @@ not ok 55 - custom inspect symbol that throws fail
*
*
...
# Subtest: sync throw fails at second
not ok 2 - sync throw fails at second
---
duration_ms: *
Expand All @@ -563,6 +563,7 @@ not ok 56 - subtest sync throw fails
error: '2 subtests failed'
code: 'ERR_TEST_FAILURE'
...
# Subtest: invalid subtest fail
not ok 57 - invalid subtest fail
---
duration_ms: *
Expand Down

0 comments on commit 6ae4e74

Please sign in to comment.