Skip to content

Commit 55c23c5

Browse files
committed
Prune some excessive diagnostic output
Also, move the code around a little bit so that it'll be more straightforward to have yaml diagnostics ahead of buffered child test output once that's supported by the parser.
1 parent 8aeb886 commit 55c23c5

33 files changed

+59
-263
lines changed

lib/test.js

+49-34
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ function loop (self, arr, cb, i) {
553553
}
554554
}
555555

556+
function childExtra (extra, results) {
557+
if (results && results.failures) {
558+
extra.failures = results.failures
559+
}
560+
extra.at = null
561+
delete extra.stack
562+
}
563+
556564
Test.prototype._runChild = function runChild (child, name, extra, cb) {
557565
var self = this
558566
var results
@@ -562,7 +570,7 @@ Test.prototype._runChild = function runChild (child, name, extra, cb) {
562570
})
563571
child.on('end', function () {
564572
ended = true
565-
extra.results = results
573+
childExtra(extra, results)
566574
self._currentChild = null
567575
var time = results ? '# time=' + results.time + 'ms' : ''
568576
if (extra.buffered) {
@@ -573,10 +581,9 @@ Test.prototype._runChild = function runChild (child, name, extra, cb) {
573581
}
574582

575583
// if the child already bailed, then don't _also_ bail for this
576-
self.ok(child._ok, child._name, {
577-
_tapChildBuffer: child._buffer,
578-
_tapChildBailed: child._bailedOut
579-
})
584+
extra._tapChildBuffer = child._buffer
585+
extra._tapChildBailed = child._bailedOut
586+
self.ok(child._ok, child._name, extra)
580587

581588
if (endThis) {
582589
self._ending = false
@@ -901,7 +908,8 @@ Test.prototype.spawn = function spawnTest (cmd, args, options, name, extra, defe
901908
child.on('close', function onclose (code, signal) {
902909
clearTimeout(timer)
903910
self._currentChild = null
904-
extra.results = results
911+
childExtra(extra, results)
912+
905913
var dur = process.hrtime(start)
906914
var time = Math.round(dur[0] * 1e6 + dur[1] / 1e3) / 1e3
907915
time = '# time=' + time + 'ms'
@@ -918,7 +926,8 @@ Test.prototype.spawn = function spawnTest (cmd, args, options, name, extra, defe
918926
results.ok = false
919927
}
920928

921-
if (results && results.count === 0 && !signal && !code && !results.bailout) {
929+
if (results && results.count === 0 &&
930+
!signal && !code && !results.bailout) {
922931
extra.skip = 'No tests found'
923932
if (results.plan && results.plan.skipReason) {
924933
extra.skip = results.plan.skipReason
@@ -1337,6 +1346,7 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
13371346
var bailed = false
13381347
if (extra._tapChildBuffer) {
13391348
buffer = extra._tapChildBuffer
1349+
extra.buffered = true
13401350
delete extra._tapChildBuffer
13411351
if (extra._tapChildBailed) {
13421352
bailed = true
@@ -1393,8 +1403,34 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
13931403
}
13941404
}
13951405

1406+
var diagnostic = process.env.TAP_DIAG === '1'
1407+
if (!ok) {
1408+
diagnostic = true
1409+
}
1410+
if (extra.skip) {
1411+
diagnostic = false
1412+
}
1413+
if (process.env.TAP_DIAG === '0') {
1414+
diagnostic = false
1415+
}
1416+
if (typeof extra.diagnostic === 'boolean') {
1417+
diagnostic = extra.diagnostic
1418+
}
13961419
if (buffer) {
1397-
this.push(' {')
1420+
// XXX remove when parser can handle diags along with buffer
1421+
diagnostic = false
1422+
}
1423+
if (diagnostic) {
1424+
diagnostic = this.writeDiags(extra)
1425+
}
1426+
1427+
// If we're skipping, no need for diags.
1428+
// Also, never print diags if there's a child buffer to show
1429+
if (buffer) {
1430+
if (!diagnostic) {
1431+
this.push(' ')
1432+
}
1433+
this.push('{')
13981434
}
13991435

14001436
if (!ok && !extra.todo && !extra.skip) {
@@ -1403,28 +1439,9 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
14031439

14041440
this.push('\n')
14051441

1406-
// If we're skipping, no need for diags.
1407-
// Also, never print diags if there's a child buffer to show
14081442
if (buffer) {
14091443
var b = buffer.trim().split('\n').join('\n ') + '\n'
14101444
this.push(' ' + b + '}\n')
1411-
} else {
1412-
var diagnostic = process.env.TAP_DIAG === '1'
1413-
if (!ok) {
1414-
diagnostic = true
1415-
}
1416-
if (extra.skip) {
1417-
diagnostic = false
1418-
}
1419-
if (process.env.TAP_DIAG === '0') {
1420-
diagnostic = false
1421-
}
1422-
if (typeof extra.diagnostic === 'boolean') {
1423-
diagnostic = extra.diagnostic
1424-
}
1425-
if (diagnostic) {
1426-
this.writeDiags(extra)
1427-
}
14281445
}
14291446

14301447
if (this._bail && !ok && !extra.skip && !extra.todo && !bailed) {
@@ -1449,10 +1466,12 @@ function yamlFilter (propertyName, isRoot, source, target) {
14491466
}
14501467

14511468
return !(propertyName === 'todo' ||
1469+
propertyName === '_tapChildBuffer' ||
1470+
propertyName === '_tapChildBailed' ||
14521471
propertyName === 'skip' ||
14531472
propertyName === 'diagnostic' ||
14541473
propertyName === 'buffered' ||
1455-
(propertyName === 'at' && !source[propertyName]))
1474+
(propertyName === 'at' && !source.at))
14561475
}
14571476

14581477
Test.prototype.writeDiags = function (extra) {
@@ -1479,19 +1498,15 @@ Test.prototype.writeDiags = function (extra) {
14791498
}
14801499
}
14811500

1482-
if (extra.buffered === true || extra.buffered === false) {
1483-
delete extra.buffered
1484-
}
1485-
14861501
// some objects are not suitable for yaml.
14871502
var obj = cleanYamlObject(extra, yamlFilter)
14881503

14891504
if (obj && typeof obj === 'object' && Object.keys(obj).length) {
14901505
var y = yaml.safeDump(obj).split('\n').map(function (l) {
14911506
return l.trim() ? ' ' + l : l.trim()
14921507
}).join('\n')
1493-
y = ' ---\n' + y + ' ...\n'
1494-
this.push(y)
1508+
y = ' ---\n' + y + ' ...'
1509+
this.push('\n' + y)
14951510
}
14961511
}
14971512

test/test/assert-at.tap

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ TAP version 13
1919
1..4
2020
# failed 4 of 4 tests
2121
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~
22-
---
23-
{"at":{"column":3,"file":"test/test/assert-at.js","line":33},"results":{"count":4,"fail":4,"ok":false,"pass":0,"plan":{"end":4,"start":1}},"source":"t.test(foo)\n"}
24-
...
2522

2623
1..1
2724
# failed 1 of 1 tests

test/test/before-after-each-promise.tap

-9
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,17 @@ after 2 undefined
1717
1..2
1818
# failed 1 of 2 tests
1919
not ok 1 - grandchild ___/# time=[0-9.]+(ms)?/~~~
20-
---
21-
{"at":{"column":7,"file":"test/test/before-after-each-promise.js","line":35},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1}},"source":"t.test('grandchild', function (t) {\n"}
22-
...
2320

2421
after 2 undefined
2522
after 1 child
2623
1..1
2724
# failed 1 of 1 tests
2825
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~
29-
---
30-
{"at":{"column":5,"file":"test/test/before-after-each-promise.js","line":34},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('child', function (t) {\n"}
31-
...
3226

3327
after 1 parent
3428
1..1
3529
# failed 1 of 1 tests
3630
not ok 1 - parent ___/# time=[0-9.]+(ms)?/~~~
37-
---
38-
{"at":{"column":3,"file":"test/test/before-after-each-promise.js","line":17},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('parent', function (t) {\n"}
39-
...
4031

4132
1..1
4233
# failed 1 of 1 tests

test/test/before-after-each-raise.tap

-9
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,17 @@ after 2 grandchild
1616
1..2
1717
# failed 1 of 2 tests
1818
not ok 1 - grandchild ___/# time=[0-9.]+(ms)?/~~~
19-
---
20-
{"at":{"column":7,"file":"test/test/before-after-each-raise.js","line":28},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1}},"source":"t.test('grandchild', function (t) {\n"}
21-
...
2219

2320
after 2 child
2421
after 1 child
2522
1..1
2623
# failed 1 of 1 tests
2724
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~
28-
---
29-
{"at":{"column":5,"file":"test/test/before-after-each-raise.js","line":27},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('child', function (t) {\n"}
30-
...
3125

3226
after 1 parent
3327
1..1
3428
# failed 1 of 1 tests
3529
not ok 1 - parent ___/# time=[0-9.]+(ms)?/~~~
36-
---
37-
{"at":{"column":3,"file":"test/test/before-after-each-raise.js","line":13},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('parent', function (t) {\n"}
38-
...
3930

4031
done
4132
1..1

test/test/before-after-each-throw.tap

-9
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,17 @@ after 2 grandchild
1616
1..2
1717
# failed 1 of 2 tests
1818
not ok 1 - grandchild ___/# time=[0-9.]+(ms)?/~~~
19-
---
20-
{"at":{"column":7,"file":"test/test/before-after-each-throw.js","line":30},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1}},"source":"t.test('grandchild', function (t) {\n"}
21-
...
2219

2320
after 2 child
2421
after 1 child
2522
1..1
2623
# failed 1 of 1 tests
2724
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~
28-
---
29-
{"at":{"column":5,"file":"test/test/before-after-each-throw.js","line":29},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('child', function (t) {\n"}
30-
...
3125

3226
after 1 parent
3327
1..1
3428
# failed 1 of 1 tests
3529
not ok 1 - parent ___/# time=[0-9.]+(ms)?/~~~
36-
---
37-
{"at":{"column":3,"file":"test/test/before-after-each-throw.js","line":13},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('parent', function (t) {\n"}
38-
...
3930

4031
done
4132
1..1

test/test/equivalent.tap

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ TAP version 13
2727
1..6
2828
# failed 6 of 6 tests
2929
not ok 1 - child test ___/# time=[0-9.]+(ms)?/~~~
30-
---
31-
{"at":{"column":3,"file":"test/test/equivalent.js","line":2},"results":{"count":6,"fail":6,"ok":false,"pass":0,"plan":{"end":6,"start":1}},"source":"t.test('child test', function (t) {\n"}
32-
...
3330

3431
1..1
3532
# failed 1 of 1 tests

test/test/mochalike.tap

-15
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ ok 4 - reasonably indented things ___/# time=[0-9.]+(ms)?/~~~
5252
# failed 1 of 2 tests
5353
# todo: 2
5454
not ok 1 - first subset ___/# time=[0-9.]+(ms)?/~~~
55-
---
56-
{"at":{"column":3,"file":"test/test/mochalike.js","line":52},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1},"todo":2},"source":"describe('first subset', function () {\n"}
57-
...
5855

5956
# Subtest: second subset
6057
not ok 1 - AssertionError: objectify the truthiness
@@ -64,16 +61,10 @@ ok 4 - reasonably indented things ___/# time=[0-9.]+(ms)?/~~~
6461
1..1
6562
# failed 1 of 1 tests
6663
not ok 2 - second subset ___/# time=[0-9.]+(ms)?/~~~
67-
---
68-
{"at":{"column":3,"file":"test/test/mochalike.js","line":59},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"describe('second subset', function () {\n"}
69-
...
7064

7165
1..2
7266
# failed 2 of 2 tests
7367
not ok 5 - failing indented things ___/# time=[0-9.]+(ms)?/~~~
74-
---
75-
{"at":{"column":1,"file":"test/test/mochalike.js","line":51},"results":{"count":2,"fail":2,"ok":false,"pass":0,"plan":{"end":2,"start":1}},"source":"describe('failing indented things', function () {\n"}
76-
...
7768

7869
# Subtest: a test passing an error to done() callback
7970
# Subtest: is marked as failed
@@ -84,16 +75,10 @@ not ok 5 - failing indented things ___/# time=[0-9.]+(ms)?/~~~
8475
1..1
8576
# failed 1 of 1 tests
8677
not ok 1 - is marked as failed ___/# time=[0-9.]+(ms)?/~~~
87-
---
88-
{"at":{"column":3,"file":"test/test/mochalike.js","line":66},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"it('is marked as failed', function (done) {\n"}
89-
...
9078

9179
1..1
9280
# failed 1 of 1 tests
9381
not ok 6 - a test passing an error to done() callback ___/# time=[0-9.]+(ms)?/~~~
94-
---
95-
{"at":{"column":1,"file":"test/test/mochalike.js","line":65},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"describe('a test passing an error to done() callback', function () {\n"}
96-
...
9782

9883
1..6
9984
# failed 2 of 6 tests

test/test/nesting.tap

-9
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ TAP version 13
1717
1..3
1818
# failed 1 of 3 tests
1919
not ok 2 - second ___/# time=[0-9.]+(ms)?/~~~
20-
---
21-
{"at":{"column":5,"file":"test/test/nesting.js","line":10},"results":{"count":3,"fail":1,"ok":false,"pass":2,"plan":{"end":3,"start":1}},"source":"t.test('second', function (tt) {\n"}
22-
...
2320

2421
# failed 1 of 2 tests
2522
not ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~
26-
---
27-
{"at":{"column":3,"file":"test/test/nesting.js","line":3},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1}},"source":"t.test('nesting', function (t) {\n"}
28-
...
2923

3024
ok 2 - this passes
3125
not ok 3 - this fails
@@ -41,9 +35,6 @@ not ok 3 - this fails
4135
...
4236
# failed 1 of 2 tests
4337
not ok 4 - async kid ___/# time=[0-9.]+(ms)?/~~~
44-
---
45-
{"at":{"column":3,"file":"test/test/nesting.js","line":30},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1}},"source":"t.test('async kid', function (t) {\n"}
46-
...
4738

4839
ok 5 - pass after async kid
4940
1..5

test/test/not-ok-nested.tap

-6
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@ TAP version 13
99
...
1010
# failed 1 of 1 tests
1111
not ok 1 - parent ___/# time=[0-9.]+(ms)?/~~~
12-
---
13-
{"at":{"column":5,"file":"test/test/not-ok-nested.js","line":5},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('parent', function (t) {\n"}
14-
...
1512

1613
# failed 1 of 1 tests
1714
not ok 1 - gp ___/# time=[0-9.]+(ms)?/~~~
18-
---
19-
{"at":{"column":3,"file":"test/test/not-ok-nested.js","line":3},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('gp', function (t) {\n"}
20-
...
2115

2216
1..1
2317
# failed 1 of 1 tests

test/test/ok-diags--bail.tap

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ ok 1 - this is fine
77
1..1
88
ok 1 - this is fine
99
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~
10-
---
11-
{"at":{"column":3,"file":"test/test/ok-diags.js","line":10},"results":{"count":1,"ok":true,"pass":1,"plan":{"end":1,"start":1}},"source":"t.test('child', { diagnostic: true }, function (t) {\n"}
12-
...
1310

1411
1..2
1512
___/# time=[0-9.]+(ms)?/~~~

test/test/ok-diags.tap

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ ok 1 - this is fine
77
1..1
88
ok 1 - this is fine
99
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~
10-
---
11-
{"at":{"column":3,"file":"test/test/ok-diags.js","line":10},"results":{"count":1,"ok":true,"pass":1,"plan":{"end":1,"start":1}},"source":"t.test('child', { diagnostic: true }, function (t) {\n"}
12-
...
1310

1411
1..2
1512
___/# time=[0-9.]+(ms)?/~~~

test/test/pending-handles.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TAP version 13
1010
___/# time=[0-9.]+(ms)?/~~~
1111
not ok 1 - ___/.*/~~~pending-handles.js child ___/# time=[0-9.]+(ms)?/~~~
1212
---
13-
{"arguments":["___/.*/~~~pending-handles.js","child"],"at":{"column":5,"file":"test/test/pending-handles.js","line":7},"command":"___/.*(node|iojs)(.exe)?/~~~","failure":"timeout","results":{"bailout":false,"count":2,"fail":1,"ok":false,"pass":1,"plan":{"comment":"","end":2,"skipAll":false,"skipReason":"","start":1},"skip":0,"todo":0},"signal":"SIGTERM","source":"t.spawn(process.execPath, [__filename, 'child'], {}, '', {\n","timeout":900}
13+
{"arguments":["___/.*/~~~pending-handles.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~","failure":"timeout","signal":"SIGTERM","timeout":900}
1414
...
1515

1616
1..1

0 commit comments

Comments
 (0)