Skip to content

Commit

Permalink
tests for expected buffer output
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 3, 2017
1 parent 4d481a3 commit 7ac36fd
Show file tree
Hide file tree
Showing 169 changed files with 401 additions and 638 deletions.
25 changes: 17 additions & 8 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,10 @@ Test.prototype._runChild = function runChild (child, name, extra, cb) {
self._ending = true
}

// if the child already bailed, then don't _also_ bail for this
self.ok(child._ok, child._name, {
_tapChildBuffer: child._buffer
_tapChildBuffer: child._buffer,
_tapChildBailed: child._bailedOut
})

if (endThis) {
Expand All @@ -591,9 +593,9 @@ Test.prototype._runChild = function runChild (child, name, extra, cb) {
child.on('bailout', function (message) {
if (extra.buffered) {
self._currentChild = null
self._bail = false
self.fail(child._name, {
_tapChildBuffer: child._buffer
_tapChildBuffer: child._buffer,
_tapChildBailed: true
})
}
rootBail(self, message)
Expand Down Expand Up @@ -721,11 +723,11 @@ function pruneFailures (res) {
function rootBail (self, message) {
var p = self
while (p._parent) {
p._bailedOut = true
// end any buffered tests along the way
if (p._buffered) {
p.emit('end')
}
p._bailedOut = true
p = p._parent
}
p.bailout(message)
Expand Down Expand Up @@ -935,6 +937,7 @@ Test.prototype.spawn = function spawnTest (cmd, args, options, name, extra, defe
var ok = results.ok && !code && !signal
if (extra.buffered) {
extra._tapChildBuffer = buffer
extra._tapChildBailed = child._bailedOut
}
self.ok(ok, name, extra)
if (!self._ended) {
Expand Down Expand Up @@ -1355,11 +1358,17 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
}

var buffer
var bailed = false
if (extra._tapChildBuffer) {
buffer = extra._tapChildBuffer
delete extra._tapChildBuffer
if (extra._tapChildBailed) {
bailed = true
delete extra._tapChildBailed
}
}


var res = { ok: ok, message: message, extra: extra }

if (extra.todo) {
Expand Down Expand Up @@ -1388,12 +1397,12 @@ Test.prototype.printResult = function printResult (ok, message, extra) {

message = message.replace(/[\n\r]/g, ' ').replace(/\t/g, ' ')

this.push(util.format('%s %d%s', ok ? 'ok' : 'not ok', n, message))

if (buffer) {
message += ' {'
this.push(' {')
}

this.push(util.format('%s %d%s', ok ? 'ok' : 'not ok', n, message))

var ending = false
if (n === this._plan) {
ending = true
Expand Down Expand Up @@ -1442,7 +1451,7 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
}
}

if (this._bail && !ok && !extra.skip && !extra.todo && message.slice(-1) !== '{') {
if (this._bail && !ok && !extra.skip && !extra.todo && !bailed) {
this.bailout(message.replace(/^ - /, ''))
}

Expand Down
1 change: 0 additions & 1 deletion test/test/assert-at-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ not ok 1 - foo {
...
Bail out! # baz
}

Bail out! # baz

1 change: 0 additions & 1 deletion test/test/assert-at-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ not ok 1 - foo {
...
1..4
# failed 4 of 4 tests
___/# time=[0-9.]+(ms)?/~~~
}

1..1
Expand Down
1 change: 0 additions & 1 deletion test/test/assert-todo-skip-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ok 1 - not much {
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":11},"source":"t.ok(false, 'expected without explanation', {todo: true})\n"}
...
1..8
___/# time=[0-9.]+(ms)?/~~~
}

1..1
Expand Down
1 change: 0 additions & 1 deletion test/test/assert-todo-skip-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ok 1 - not much {
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":11},"source":"t.ok(false, 'expected without explanation', {todo: true})\n"}
...
1..8
___/# time=[0-9.]+(ms)?/~~~
}

1..1
Expand Down
2 changes: 0 additions & 2 deletions test/test/async-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ TAP version 13
ok 1 - first test {
ok 1 - this is ok
1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - second test (async) {
ok 1 - this is ok
1..1
___/# time=[0-9.]+(ms)?/~~~
}

1..2
Expand Down
2 changes: 0 additions & 2 deletions test/test/async-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ TAP version 13
ok 1 - first test {
ok 1 - this is ok
1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - second test (async) {
ok 1 - this is ok
1..1
___/# time=[0-9.]+(ms)?/~~~
}

1..2
Expand Down
2 changes: 0 additions & 2 deletions test/test/bail-child-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ not ok 1 - bail fail {
...
Bail out! # this fails
}

Bail out! # this fails
}

Bail out! # this fails
Expand Down
2 changes: 0 additions & 2 deletions test/test/bail-child-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ not ok 1 - bail fail {
...
Bail out! # this fails
}

Bail out! # this fails
}

Bail out! # this fails
Expand Down
24 changes: 22 additions & 2 deletions test/test/bail-fail-spawn-bail-buffer.tap
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - ./test/test/nesting.js {
Bail out! # ./test/test/nesting.js {
not ok 1 - nesting {
1..2
ok 1 - first {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
}

not ok 2 - second {
ok 1 - but that is ok
ok 2 - this passes
not ok 3 - nested failure
---
{"at":{"column":10,"file":"test/test/nesting.js","function":"foo","line":14},"compare":"===","found":1,"source":"tt.equal(1, '1', 'nested failure')\n","wanted":"1"}
...
Bail out! # nested failure
}
}

Bail out! # nested failure
}
}

Bail out! # ./test/test/nesting.js {
Bail out! # nested failure

2 changes: 1 addition & 1 deletion test/test/bail-fail-spawn-bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TAP version 13
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

# Subtest: second
ok 1 - but that is ok
ok 2 - this passes
Expand Down
24 changes: 22 additions & 2 deletions test/test/bail-fail-spawn-buffer.tap
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - ./test/test/nesting.js {
Bail out! # ./test/test/nesting.js {
not ok 1 - nesting {
1..2
ok 1 - first {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
}

not ok 2 - second {
ok 1 - but that is ok
ok 2 - this passes
not ok 3 - nested failure
---
{"at":{"column":10,"file":"test/test/nesting.js","function":"foo","line":14},"compare":"===","found":1,"source":"tt.equal(1, '1', 'nested failure')\n","wanted":"1"}
...
Bail out! # nested failure
}
}

Bail out! # nested failure
}
}

Bail out! # ./test/test/nesting.js {
Bail out! # nested failure

2 changes: 1 addition & 1 deletion test/test/bail-fail-spawn.tap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TAP version 13
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

# Subtest: second
ok 1 - but that is ok
ok 2 - this passes
Expand Down
7 changes: 0 additions & 7 deletions test/test/bail-teardown-async-bail-buffer.tap
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
TAP version 13
ok 1 - foobar test {
1..0
___/# time=[0-9.]+(ms)?/~~~
}

not ok 2 - barfoo {
Expand All @@ -10,14 +9,8 @@ not ok 2 - barfoo {
not ok 1 - b3rf {
Bail out! # teardown fail
}

Bail out! # teardown fail
}

Bail out! # teardown fail
}

Bail out! # teardown fail
}

Bail out! # teardown fail
Expand Down
7 changes: 0 additions & 7 deletions test/test/bail-teardown-async-buffer.tap
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
TAP version 13
ok 1 - foobar test {
1..0
___/# time=[0-9.]+(ms)?/~~~
}

not ok 2 - barfoo {
Expand All @@ -10,14 +9,8 @@ not ok 2 - barfoo {
not ok 1 - b3rf {
Bail out! # teardown fail
}

Bail out! # teardown fail
}

Bail out! # teardown fail
}

Bail out! # teardown fail
}

Bail out! # teardown fail
Expand Down
1 change: 0 additions & 1 deletion test/test/bail-teardown-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ok 1 - this is fine
ok 2 - child {
ok 1 - child test point
1..1
___/# time=[0-9.]+(ms)?/~~~
}

Bail out! # i did not want to be torn down
Expand Down
1 change: 0 additions & 1 deletion test/test/bail-teardown-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ok 1 - this is fine
ok 2 - child {
ok 1 - child test point
1..1
___/# time=[0-9.]+(ms)?/~~~
}

Bail out! # i did not want to be torn down
Expand Down
5 changes: 1 addition & 4 deletions test/test/bailout-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ ok 1 - nesting {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - second {
ok 1 - but that is ok
ok 2 - this passes
1..2
___/# time=[0-9.]+(ms)?/~~~
}
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - this passes
Expand Down
4 changes: 2 additions & 2 deletions test/test/bailout-bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ TAP version 13
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

# Subtest: second
ok 1 - but that is ok
ok 2 - this passes
1..2
ok 2 - second ___/# time=[0-9.]+(ms)?/~~~

ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~

ok 2 - this passes
Expand Down
6 changes: 1 addition & 5 deletions test/test/bailout-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ ok 1 - nesting {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - second {
ok 1 - but that is ok
ok 2 - this passes
1..2
___/# time=[0-9.]+(ms)?/~~~
}
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - this passes
Expand All @@ -26,6 +23,5 @@ not ok 4 - async kid {
1..2
Bail out! # cannot continue
}

Bail out! # cannot continue

4 changes: 2 additions & 2 deletions test/test/bailout.tap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ TAP version 13
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

# Subtest: second
ok 1 - but that is ok
ok 2 - this passes
1..2
ok 2 - second ___/# time=[0-9.]+(ms)?/~~~

ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~

ok 2 - this passes
Expand Down
7 changes: 2 additions & 5 deletions test/test/before-after-each-async-bail-buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ ok 1 - parent {
ok 1 - grandchild {
ok 1 - the only actual assertion
1..1
___/# time=[0-9.]+(ms)?/~~~
}

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

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

1..1
Expand Down
Loading

0 comments on commit 7ac36fd

Please sign in to comment.