Skip to content

Commit

Permalink
Always put a \n after a yaml diag block
Browse files Browse the repository at this point in the history
Otherwise it's pretty crowded and noisy.

However, to prevent double-spacing, also change some of the logic around
how and when subtest asserts get spaced (always putting a space after a
child test point).
  • Loading branch information
isaacs committed Jan 7, 2017
1 parent 55c23c5 commit 67ae57e
Show file tree
Hide file tree
Showing 149 changed files with 287 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ function childExtra (extra, results) {
if (results && results.failures) {
extra.failures = results.failures
}
extra._tapChild = true
extra.at = null
delete extra.stack
}
Expand Down Expand Up @@ -592,9 +593,6 @@ Test.prototype._runChild = function runChild (child, name, extra, cb) {
} else {
self.ok(child._ok, name + ' ' + time, extra)
}
if (!self._ended) {
self.push('\n')
}
})

child.on('bailout', function (message) {
Expand Down Expand Up @@ -704,9 +702,6 @@ Test.prototype.stdin = function (name, extra, deferred) {
var time = Math.round(dur[0] * 1e6 + dur[1] / 1e3) / 1e3
time = '# time=' + time + 'ms'
self.ok(res.ok, name, extra)
if (!self._ended) {
self.push('\n')
}
deferred.resolve(self)
self._processQueue()
})
Expand Down Expand Up @@ -942,9 +937,6 @@ Test.prototype.spawn = function spawnTest (cmd, args, options, name, extra, defe
extra._tapChildBailed = child._bailedOut
}
self.ok(ok, name, extra)
if (!self._ended) {
self.push('\n')
}
if (child._bailedOut) {
rootBail(self, child._bailedOut || name)
}
Expand Down Expand Up @@ -1431,6 +1423,8 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
this.push(' ')
}
this.push('{')
} else if (!diagnostic && extra._tapChild) {
this.push('\n')
}

if (!ok && !extra.todo && !extra.skip) {
Expand All @@ -1441,7 +1435,7 @@ Test.prototype.printResult = function printResult (ok, message, extra) {

if (buffer) {
var b = buffer.trim().split('\n').join('\n ') + '\n'
this.push(' ' + b + '}\n')
this.push(' ' + b + '}\n\n')
}

if (this._bail && !ok && !extra.skip && !extra.todo && !bailed) {
Expand All @@ -1466,8 +1460,7 @@ function yamlFilter (propertyName, isRoot, source, target) {
}

return !(propertyName === 'todo' ||
propertyName === '_tapChildBuffer' ||
propertyName === '_tapChildBailed' ||
/^_tapChild/.test(propertyName) ||
propertyName === 'skip' ||
propertyName === 'diagnostic' ||
propertyName === 'buffered' ||
Expand All @@ -1476,7 +1469,7 @@ function yamlFilter (propertyName, isRoot, source, target) {

Test.prototype.writeDiags = function (extra) {
if (extra.diagnostic === false) {
return
return false
}

var file = extra.at && extra.at.file && path.resolve(extra.at.file)
Expand Down Expand Up @@ -1505,9 +1498,12 @@ Test.prototype.writeDiags = function (extra) {
var y = yaml.safeDump(obj).split('\n').map(function (l) {
return l.trim() ? ' ' + l : l.trim()
}).join('\n')
y = ' ---\n' + y + ' ...'
y = ' ---\n' + y + ' ...\n'
this.push('\n' + y)
return true
}

return false
}

Test.prototype.passing = function () {
Expand Down
2 changes: 2 additions & 0 deletions test/test/assert-at--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ not ok 1 - foo {
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}
...

Bail out! # baz
}

Bail out! # baz

1 change: 1 addition & 0 deletions test/test/assert-at--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ TAP version 13
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}
...

Bail out! # baz
Bail out! # baz

4 changes: 4 additions & 0 deletions test/test/assert-at--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ not ok 1 - foo {
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}
...

not ok 2 - bler
---
{"at":{"column":5,"file":"test/test/assert-at.js","function":"bler","line":25},"source":"t.fail('bler')\n"}
...

not ok 3 - bar
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"bar","line":10},"source":"baz(t)\n"}
...

not ok 4 - bar stack
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"bar","line":10},"source":"baz(t)\n"}
...

1..4
# failed 4 of 4 tests
}
Expand Down
4 changes: 4 additions & 0 deletions test/test/assert-at.tap
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ TAP version 13
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}
...

not ok 2 - bler
---
{"at":{"column":5,"file":"test/test/assert-at.js","function":"bler","line":25},"source":"t.fail('bler')\n"}
...

not ok 3 - bar
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"bar","line":10},"source":"baz(t)\n"}
...

not ok 4 - bar stack
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"bar","line":10},"source":"baz(t)\n"}
...

1..4
# failed 4 of 4 tests
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~
Expand Down
2 changes: 2 additions & 0 deletions test/test/assert-todo-skip--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ ok 1 - not much {
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":7},"source":"t.ok(false, 'expected', {todo: 'implement a thing'})\n"}
...

ok 5 - always passes without explanation # SKIP
not ok 6 - false without explanation # SKIP
ok 7 - bonus without explanation # TODO
not ok 8 - expected without explanation # TODO
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":11},"source":"t.ok(false, 'expected without explanation', {todo: true})\n"}
...

1..8
}

Expand Down
2 changes: 2 additions & 0 deletions test/test/assert-todo-skip--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ TAP version 13
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":7},"source":"t.ok(false, 'expected', {todo: 'implement a thing'})\n"}
...

ok 5 - always passes without explanation # SKIP
not ok 6 - false without explanation # SKIP
ok 7 - bonus without explanation # TODO
not ok 8 - expected without explanation # TODO
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":11},"source":"t.ok(false, 'expected without explanation', {todo: true})\n"}
...

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

Expand Down
2 changes: 2 additions & 0 deletions test/test/assert-todo-skip--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ ok 1 - not much {
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":7},"source":"t.ok(false, 'expected', {todo: 'implement a thing'})\n"}
...

ok 5 - always passes without explanation # SKIP
not ok 6 - false without explanation # SKIP
ok 7 - bonus without explanation # TODO
not ok 8 - expected without explanation # TODO
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":11},"source":"t.ok(false, 'expected without explanation', {todo: true})\n"}
...

1..8
}

Expand Down
2 changes: 2 additions & 0 deletions test/test/assert-todo-skip.tap
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ TAP version 13
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":7},"source":"t.ok(false, 'expected', {todo: 'implement a thing'})\n"}
...

ok 5 - always passes without explanation # SKIP
not ok 6 - false without explanation # SKIP
ok 7 - bonus without explanation # TODO
not ok 8 - expected without explanation # TODO
---
{"at":{"column":5,"file":"test/test/assert-todo-skip.js","line":11},"source":"t.ok(false, 'expected without explanation', {todo: true})\n"}
...

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

Expand Down
1 change: 1 addition & 0 deletions test/test/bail-child--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ not ok 1 - bail fail {
---
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}
...

Bail out! # this fails
}
}
Expand Down
1 change: 1 addition & 0 deletions test/test/bail-child--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ TAP version 13
---
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}
...

Bail out! # this fails
Bail out! # this fails

1 change: 1 addition & 0 deletions test/test/bail-child--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ not ok 1 - bail fail {
---
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}
...

Bail out! # this fails
}
}
Expand Down
1 change: 1 addition & 0 deletions test/test/bail-child.tap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ TAP version 13
---
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}
...

Bail out! # this fails
Bail out! # this fails

1 change: 1 addition & 0 deletions test/test/bailout--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ not ok 3 - this fails
---
{"at":{"column":3,"file":"test/test/bailout.js","line":18},"source":"t.fail('this fails')\n"}
...

Bail out! # this fails

1 change: 1 addition & 0 deletions test/test/bailout--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ not ok 3 - this fails
---
{"at":{"column":3,"file":"test/test/bailout.js","line":18},"source":"t.fail('this fails')\n"}
...

Bail out! # this fails

2 changes: 2 additions & 0 deletions test/test/bailout--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ not ok 3 - this fails
---
{"at":{"column":3,"file":"test/test/bailout.js","line":18},"source":"t.fail('this fails')\n"}
...

not ok 4 - async kid {
1..2
Bail out! # cannot continue
}

Bail out! # cannot continue

1 change: 1 addition & 0 deletions test/test/bailout.tap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ not ok 3 - this fails
---
{"at":{"column":3,"file":"test/test/bailout.js","line":18},"source":"t.fail('this fails')\n"}
...

# Subtest: async kid
1..2
Bail out! # cannot continue
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-plan--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ok 1 - parent {
}
}
}

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

1 change: 1 addition & 0 deletions test/test/before-after-each-plan--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ after 1 child

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

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

1 change: 1 addition & 0 deletions test/test/before-after-each-plan--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ok 1 - parent {
}
}
}

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

1 change: 1 addition & 0 deletions test/test/before-after-each-plan.tap
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ after 1 child

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

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

1 change: 1 addition & 0 deletions test/test/before-after-each-promise--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ not ok 1 - parent {
---
{"at":{"column":23,"file":"test/test/before-after-each-promise.js","line":28},"message":"Error: this is fine","source":"return reject(new Error('this is fine'))\n","test":"grandchild"}
...

Bail out! # Error: this is fine
}
}
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-promise--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ after 2 undefined
---
{"at":{"column":23,"file":"test/test/before-after-each-promise.js","line":28},"message":"Error: this is fine","source":"return reject(new Error('this is fine'))\n","test":"grandchild"}
...

Bail out! # Error: this is fine
Bail out! # Error: this is fine

1 change: 1 addition & 0 deletions test/test/before-after-each-promise--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ not ok 1 - parent {
---
{"at":{"column":23,"file":"test/test/before-after-each-promise.js","line":28},"message":"Error: this is fine","source":"return reject(new Error('this is fine'))\n","test":"grandchild"}
...

1..2
# failed 1 of 2 tests
}
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-promise.tap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ after 2 undefined
---
{"at":{"column":23,"file":"test/test/before-after-each-promise.js","line":28},"message":"Error: this is fine","source":"return reject(new Error('this is fine'))\n","test":"grandchild"}
...

1..2
# failed 1 of 2 tests
not ok 1 - grandchild ___/# time=[0-9.]+(ms)?/~~~
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-raise--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ not ok 1 - parent {
---
{"at":{"column":17,"file":"test/test/before-after-each-raise.js","function":"Test.<anonymous>","line":22},"message":"Error: this is fine","source":"return cb(new Error('this is fine'))\n","test":"grandchild"}
...

Bail out! # Error: this is fine
}
}
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-raise--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ after 2 grandchild
---
{"at":{"column":17,"file":"test/test/before-after-each-raise.js","function":"Test.<anonymous>","line":22},"message":"Error: this is fine","source":"return cb(new Error('this is fine'))\n","test":"grandchild"}
...

Bail out! # Error: this is fine
Bail out! # Error: this is fine

1 change: 1 addition & 0 deletions test/test/before-after-each-raise--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ not ok 1 - parent {
---
{"at":{"column":17,"file":"test/test/before-after-each-raise.js","function":"Test.<anonymous>","line":22},"message":"Error: this is fine","source":"return cb(new Error('this is fine'))\n","test":"grandchild"}
...

1..2
# failed 1 of 2 tests
}
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-raise.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ after 2 grandchild
---
{"at":{"column":17,"file":"test/test/before-after-each-raise.js","function":"Test.<anonymous>","line":22},"message":"Error: this is fine","source":"return cb(new Error('this is fine'))\n","test":"grandchild"}
...

1..2
# failed 1 of 2 tests
not ok 1 - grandchild ___/# time=[0-9.]+(ms)?/~~~
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-throw--bail--buffer.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ not ok 1 - parent {
---
{"at":{"column":16,"file":"test/test/before-after-each-throw.js","function":"Test.<anonymous>","line":22},"message":"Error: this is fine","source":"var er = new Error('this is fine')\n","test":"grandchild"}
...

Bail out! # Error: this is fine
}
}
Expand Down
1 change: 1 addition & 0 deletions test/test/before-after-each-throw--bail.tap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ after 2 grandchild
---
{"at":{"column":16,"file":"test/test/before-after-each-throw.js","function":"Test.<anonymous>","line":22},"message":"Error: this is fine","source":"var er = new Error('this is fine')\n","test":"grandchild"}
...

Bail out! # Error: this is fine
Bail out! # Error: this is fine

Loading

0 comments on commit 67ae57e

Please sign in to comment.