Skip to content

Commit dda64dd

Browse files
MoLowtargos
authored andcommitted
test_runner: add Subtest to tap protocol output
PR-URL: #43417 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3247280 commit dda64dd

6 files changed

+109
-0
lines changed

lib/internal/test_runner/tap_stream.js

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class TapStream extends Readable {
7171
return `TODO${reason ? ` ${tapEscape(reason)}` : ''}`;
7272
}
7373

74+
subtest(indent, name) {
75+
this.#tryPush(`${indent}# Subtest: ${tapEscape(name)}\n`);
76+
}
77+
7478
details(indent, duration, error) {
7579
let details = `${indent} ---\n`;
7680

lib/internal/test_runner/test.js

+6
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ class Test extends AsyncResource {
183183
return;
184184
}
185185

186+
if (i === 1 && this.parent !== null) {
187+
this.reporter.subtest(this.indent, this.name);
188+
}
189+
186190
// Report the subtest's results and remove it from the ready map.
187191
subtest.finalize();
188192
this.readySubtests.delete(i);
@@ -416,6 +420,8 @@ class Test extends AsyncResource {
416420
// Output this test's results and update the parent's waiting counter.
417421
if (this.subtests.length > 0) {
418422
this.reporter.plan(this.subtests[0].indent, this.subtests.length);
423+
} else {
424+
this.reporter.subtest(this.indent, this.name);
419425
}
420426

421427
this.report();

test/message/test_runner_no_refs.out

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
TAP version 13
2+
# Subtest: does not keep event loop alive
3+
# Subtest: +does not keep event loop alive
24
not ok 1 - +does not keep event loop alive
35
---
46
duration_ms: *

test/message/test_runner_only_tests.out

+23
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,97 @@
11
TAP version 13
2+
# Subtest: only = undefined
23
ok 1 - only = undefined # SKIP 'only' option not set
34
---
45
duration_ms: *
56
...
7+
# Subtest: only = undefined, skip = string
68
ok 2 - only = undefined, skip = string # SKIP 'only' option not set
79
---
810
duration_ms: *
911
...
12+
# Subtest: only = undefined, skip = true
1013
ok 3 - only = undefined, skip = true # SKIP 'only' option not set
1114
---
1215
duration_ms: *
1316
...
17+
# Subtest: only = undefined, skip = false
1418
ok 4 - only = undefined, skip = false # SKIP 'only' option not set
1519
---
1620
duration_ms: *
1721
...
22+
# Subtest: only = false
1823
ok 5 - only = false # SKIP 'only' option not set
1924
---
2025
duration_ms: *
2126
...
27+
# Subtest: only = false, skip = string
2228
ok 6 - only = false, skip = string # SKIP 'only' option not set
2329
---
2430
duration_ms: *
2531
...
32+
# Subtest: only = false, skip = true
2633
ok 7 - only = false, skip = true # SKIP 'only' option not set
2734
---
2835
duration_ms: *
2936
...
37+
# Subtest: only = false, skip = false
3038
ok 8 - only = false, skip = false # SKIP 'only' option not set
3139
---
3240
duration_ms: *
3341
...
42+
# Subtest: only = true, skip = string
3443
ok 9 - only = true, skip = string # SKIP skip message
3544
---
3645
duration_ms: *
3746
...
47+
# Subtest: only = true, skip = true
3848
ok 10 - only = true, skip = true # SKIP
3949
---
4050
duration_ms: *
4151
...
52+
# Subtest: only = true, with subtests
53+
# Subtest: running subtest 1
4254
ok 1 - running subtest 1
4355
---
4456
duration_ms: *
4557
...
58+
# Subtest: running subtest 2
4659
ok 2 - running subtest 2
4760
---
4861
duration_ms: *
4962
...
63+
# Subtest: skipped subtest 1
5064
ok 3 - skipped subtest 1 # SKIP 'only' option not set
5165
---
5266
duration_ms: *
5367
...
68+
# Subtest: skipped subtest 2
5469
ok 4 - skipped subtest 2 # SKIP 'only' option not set
5570
---
5671
duration_ms: *
5772
...
73+
# Subtest: running subtest 3
5874
ok 5 - running subtest 3
5975
---
6076
duration_ms: *
6177
...
78+
# Subtest: running subtest 4
79+
# Subtest: running sub-subtest 1
6280
ok 1 - running sub-subtest 1
6381
---
6482
duration_ms: *
6583
...
84+
# Subtest: running sub-subtest 2
6685
ok 2 - running sub-subtest 2
6786
---
6887
duration_ms: *
6988
...
89+
# Subtest: skipped sub-subtest 1
7090
ok 3 - skipped sub-subtest 1 # SKIP 'only' option not set
7191
---
7292
duration_ms: *
7393
...
94+
# Subtest: skipped sub-subtest 2
7495
ok 4 - skipped sub-subtest 2 # SKIP 'only' option not set
7596
---
7697
duration_ms: *
@@ -80,10 +101,12 @@ ok 10 - only = true, skip = true # SKIP
80101
---
81102
duration_ms: *
82103
...
104+
# Subtest: skipped subtest 3
83105
ok 7 - skipped subtest 3 # SKIP 'only' option not set
84106
---
85107
duration_ms: *
86108
...
109+
# Subtest: skipped subtest 4
87110
ok 8 - skipped subtest 4 # SKIP
88111
---
89112
duration_ms: *

0 commit comments

Comments
 (0)