Skip to content

Commit

Permalink
Put diagnostics on buffered tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 8, 2017
1 parent 67ae57e commit 6f727c6
Show file tree
Hide file tree
Showing 31 changed files with 128 additions and 73 deletions.
16 changes: 7 additions & 9 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,11 @@ Test.prototype._runChild = function runChild (child, name, extra, cb) {
child.on('bailout', function (message) {
if (extra.buffered) {
self._currentChild = null
self.fail(child._name, {
_tapChildBuffer: child._buffer,
_tapChildBailed: true
})
extra.at = null
delete extra.stack
extra._tapChildBuffer = child._buffer
extra._tapChildBailed = true
self.fail(child._name, extra)
}
rootBail(self, message)
})
Expand Down Expand Up @@ -1081,7 +1082,7 @@ Test.prototype._end = function (implicit) {
var addMissingTestDiag = true
while (missing > 0) {
this.fail('missing test', {
at: false,
at: this._calledAt,
plan: this._plan,
count: this._count,
missing: missing,
Expand Down Expand Up @@ -1408,10 +1409,6 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
if (typeof extra.diagnostic === 'boolean') {
diagnostic = extra.diagnostic
}
if (buffer) {
// XXX remove when parser can handle diags along with buffer
diagnostic = false
}
if (diagnostic) {
diagnostic = this.writeDiags(extra)
}
Expand Down Expand Up @@ -1462,6 +1459,7 @@ function yamlFilter (propertyName, isRoot, source, target) {
return !(propertyName === 'todo' ||
/^_tapChild/.test(propertyName) ||
propertyName === 'skip' ||
propertyName === 'bail' ||
propertyName === 'diagnostic' ||
propertyName === 'buffered' ||
(propertyName === 'at' && !source.at))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"signal-exit": "^3.0.0",
"stack-utils": "^0.4.0",
"tap-mocha-reporter": "^3.0.0",
"tap-parser": "^4.1.0",
"tap-parser": "^4.2.2",
"tmatch": "^3.0.0"
},
"keywords": [
Expand Down
8 changes: 2 additions & 6 deletions test/only-non-tap-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,18 @@ function runTest (t) {
ok: true,
message: /\.[\\\/]test[\\\/]only-non-tap-output.js child/,
extra: {
at: {},
results: {},
command: process.execPath,
arguments: {},
skip: 'No tests found'
skip: 'no tests found'
}
},
{
ok: true,
message: /\.[\\\/]test[\\\/]only-non-tap-output.js silent/,
extra: {
at: {},
results: {},
command: process.execPath,
arguments: {},
skip: 'No tests found'
skip: 'no tests found'
}
}
])
Expand Down
22 changes: 1 addition & 21 deletions test/segv.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,12 @@ var segv =
var expect = [
'TAP version 13',
'# Subtest: ./segv ',
' 1..0',
' 1..0 # no tests found',
'not ok 1 - ./segv # time=',
' ---',
' at:',
' line: ',
' column: ',
' file: test/segv.js',
' results:',
' ok: false',
' count: 0',
' pass: 0',
' fail: 0',
' bailout: false',
' todo: 0',
' skip: 0',
' plan:',
' start: 1',
' end: 0',
' skipAll: true',
' skipReason: \'\'',
' comment: \'\'',
' signal: SIG',
' command: ./segv',
' arguments: []',
' source: |',
' tt.spawn(\'./segv\')',
' ...',
'',
'1..1',
Expand Down
6 changes: 5 additions & 1 deletion test/test/bail-fail-spawn--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - ./test/test/nesting.js {
not ok 1 - ./test/test/nesting.js
---
{"arguments":["/Users/isaacs/dev/js/tap/test/test/nesting.js"],"command":"___/.*(node|iojs)(.exe)?/~~~"}
...
{
not ok 1 - nesting {
1..2
ok 1 - first {
Expand Down
6 changes: 5 additions & 1 deletion test/test/bail-fail-spawn--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - ./test/test/nesting.js {
not ok 1 - ./test/test/nesting.js
---
{"arguments":["/Users/isaacs/dev/js/tap/test/test/nesting.js"],"command":"___/.*(node|iojs)(.exe)?/~~~"}
...
{
not ok 1 - nesting {
1..2
ok 1 - first {
Expand Down
6 changes: 5 additions & 1 deletion test/test/pending-handles--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - ___/.*/~~~pending-handles.js child {
not ok 1 - ___/.*/~~~pending-handles.js child
---
{"arguments":["___/.*/~~~pending-handles.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~","exitCode":1,"failure":"timeout","timeout":900}
...
{
ok 1 - this is ok
not ok 2 - timeout!
---
Expand Down
6 changes: 5 additions & 1 deletion test/test/pending-handles--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - ___/.*/~~~pending-handles.js child {
not ok 1 - ___/.*/~~~pending-handles.js child
---
{"arguments":["___/.*/~~~pending-handles.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~","failure":"timeout","signal":"SIGTERM","timeout":900}
...
{
ok 1 - this is ok
not ok 2 - timeout!
---
Expand Down
4 changes: 2 additions & 2 deletions test/test/plan-too-many--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ not ok 1 - children plan too big {

not ok 3 - missing test
---
{"count":2,"missing":6,"plan":8}
{"at":{"column":5,"file":"test/test/plan-too-many.js","line":7},"count":2,"missing":6,"plan":8,"source":"t.test('grandchild', function (tt) {\n"}
...

not ok 4 - missing test
Expand All @@ -26,7 +26,7 @@ not ok 1 - children plan too big {

not ok 4 - missing test
---
{"count":3,"missing":6,"plan":9}
{"at":{"column":3,"file":"test/test/plan-too-many.js","line":3},"count":3,"missing":6,"plan":9,"source":"t.test('children plan too big', function (t) {\n"}
...

not ok 5 - missing test
Expand Down
4 changes: 2 additions & 2 deletions test/test/plan-too-many.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TAP version 13

not ok 3 - missing test
---
{"count":2,"missing":6,"plan":8}
{"at":{"column":5,"file":"test/test/plan-too-many.js","line":7},"count":2,"missing":6,"plan":8,"source":"t.test('grandchild', function (tt) {\n"}
...

not ok 4 - missing test
Expand All @@ -26,7 +26,7 @@ TAP version 13

not ok 4 - missing test
---
{"count":3,"missing":6,"plan":9}
{"at":{"column":3,"file":"test/test/plan-too-many.js","line":3},"count":3,"missing":6,"plan":9,"source":"t.test('children plan too big', function (t) {\n"}
...

not ok 5 - missing test
Expand Down
6 changes: 5 additions & 1 deletion test/test/pragma--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TAP version 13
pragma +child
not ok 1 - ___/.*/~~~pragma.js child {
not ok 1 - ___/.*/~~~pragma.js child
---
{"arguments":["___/.*/~~~pragma.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~","failures":[{"data":"this is not tap and it is not ok\n","tapError":"Non-TAP data encountered in strict mode"}]}
...
{
this is not tap but it is ok
ok 1 - an ok test
pragma +strict
Expand Down
12 changes: 10 additions & 2 deletions test/test/pragma--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TAP version 13
pragma +child
not ok 1 - ___/.*/~~~pragma.js child {
not ok 1 - ___/.*/~~~pragma.js child
---
{"arguments":["___/.*/~~~pragma.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~","failures":[{"data":"this is not tap and it is not ok\n","tapError":"Non-TAP data encountered in strict mode"}]}
...
{
this is not tap but it is ok
ok 1 - an ok test
pragma +strict
Expand All @@ -13,7 +17,11 @@ not ok 1 - ___/.*/~~~pragma.js child {
}

pragma -child
not ok 2 - ___/.*/~~~pragma.js child bailout {
not ok 2 - ___/.*/~~~pragma.js child bailout
---
{"arguments":["___/.*/~~~pragma.js","child","bailout"],"command":"___/.*(node|iojs)(.exe)?/~~~","exitCode":1}
...
{
Bail out! # no pragmas come after bailout
}

Expand Down
6 changes: 5 additions & 1 deletion test/test/spawn--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - ___/.*/~~~spawn.js child {
not ok 1 - ___/.*/~~~spawn.js child
---
{"arguments":["___/.*/~~~spawn.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~"}
...
{
not ok 1 - nesting {
1..2
ok 1 - first {
Expand Down
6 changes: 5 additions & 1 deletion test/test/spawn--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - ___/.*/~~~spawn.js child {
not ok 1 - ___/.*/~~~spawn.js child
---
{"arguments":["___/.*/~~~spawn.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~"}
...
{
not ok 1 - nesting {
1..2
ok 1 - first {
Expand Down
4 changes: 2 additions & 2 deletions test/test/spawn-empty--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TAP version 13
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP No tests found {
1..0
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP no tests found {
1..0 # no tests found
}

1..1
Expand Down
4 changes: 2 additions & 2 deletions test/test/spawn-empty--bail.tap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TAP version 13
# Subtest: ___/.*/~~~spawn-empty.js child
1..0
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP No tests found
1..0 # no tests found
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP no tests found

1..1
___/# time=[0-9.]+(ms)?/~~~
Expand Down
4 changes: 2 additions & 2 deletions test/test/spawn-empty--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TAP version 13
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP No tests found {
1..0
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP no tests found {
1..0 # no tests found
}

1..1
Expand Down
4 changes: 2 additions & 2 deletions test/test/spawn-empty.tap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TAP version 13
# Subtest: ___/.*/~~~spawn-empty.js child
1..0
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP No tests found
1..0 # no tests found
ok 1 - ___/.*/~~~spawn-empty.js child # SKIP no tests found

1..1
___/# time=[0-9.]+(ms)?/~~~
Expand Down
6 changes: 5 additions & 1 deletion test/test/sync-timeout--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - t.end() {
not ok 1 - t.end()
---
{"timeout":50}
...
{
ok 1 - did not timeout
not ok 2 - timeout!
---
Expand Down
12 changes: 10 additions & 2 deletions test/test/sync-timeout--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - t.end() {
not ok 1 - t.end()
---
{"timeout":50}
...
{
ok 1 - did not timeout
not ok 2 - timeout!
---
Expand All @@ -10,7 +14,11 @@ not ok 1 - t.end() {
# failed 1 of 2 tests
}

not ok 2 - plan() {
not ok 2 - plan()
---
{"timeout":50}
...
{
1..1
ok 1 - did not time out
}
Expand Down
4 changes: 2 additions & 2 deletions test/test/throws-and-plans--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ not ok 4 - plans of 8 {

not ok 3 - missing test
---
{"count":2,"missing":6,"plan":8}
{"at":{"column":5,"file":"test/test/throws-and-plans.js","line":35},"count":2,"missing":6,"plan":8,"source":"t.test('sync thrower', function (tt) {\n"}
...

not ok 4 - missing test
Expand All @@ -68,7 +68,7 @@ not ok 4 - plans of 8 {

not ok 4 - missing test
---
{"count":3,"missing":5,"plan":8}
{"at":{"column":5,"file":"test/test/throws-and-plans.js","line":46},"count":3,"missing":5,"plan":8,"source":"t.test('async thrower', function (tt) {\n"}
...

not ok 5 - missing test
Expand Down
4 changes: 2 additions & 2 deletions test/test/throws-and-plans.tap
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ not ok 3 - no assert only throw ___/# time=[0-9.]+(ms)?/~~~

not ok 3 - missing test
---
{"count":2,"missing":6,"plan":8}
{"at":{"column":5,"file":"test/test/throws-and-plans.js","line":35},"count":2,"missing":6,"plan":8,"source":"t.test('sync thrower', function (tt) {\n"}
...

not ok 4 - missing test
Expand All @@ -68,7 +68,7 @@ not ok 3 - no assert only throw ___/# time=[0-9.]+(ms)?/~~~

not ok 4 - missing test
---
{"count":3,"missing":5,"plan":8}
{"at":{"column":5,"file":"test/test/throws-and-plans.js","line":46},"count":3,"missing":5,"plan":8,"source":"t.test('async thrower', function (tt) {\n"}
...

not ok 5 - missing test
Expand Down
6 changes: 5 additions & 1 deletion test/test/timeout--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TAP version 13
not ok 1 - parent of timeout test {
not ok 1 - timeout test {
not ok 1 - timeout test
---
{"timeout":50}
...
{
not ok 1 - this never completes {
not ok 1 - baby {
ok 1 - expect truthy value
Expand Down
6 changes: 5 additions & 1 deletion test/test/timeout--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
TAP version 13
not ok 1 - parent of timeout test {
not ok 1 - timeout test {
not ok 1 - timeout test
---
{"timeout":50}
...
{
not ok 1 - this never completes {
not ok 1 - baby {
ok 1 - expect truthy value
Expand Down
6 changes: 5 additions & 1 deletion test/test/timeout-via-runner--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TAP version 13
not ok 1 - child {
not ok 1 - child
---
{"arguments":["___/.*/~~~timeout-via-runner.js","child"],"command":"___/.*(node|iojs)(.exe)?/~~~","exitCode":1,"failure":"timeout","timeout":1000}
...
{
ok 1 - this is fine 1
ok 2 - this is fine 2
ok 3 - this is fine 3
Expand Down
Loading

0 comments on commit 6f727c6

Please sign in to comment.