Skip to content

Commit

Permalink
Put back the # time=... directives
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 26, 2017
1 parent 6a6faf0 commit f63ea3e
Show file tree
Hide file tree
Showing 251 changed files with 832 additions and 818 deletions.
10 changes: 10 additions & 0 deletions lib/base.js
Expand Up @@ -21,6 +21,8 @@ var ownOrEnv = require('own-or-env')

function Base (options) {
this.start = 0
this.hrtime = null
this.time = null
this.readyToProcess = false
this.options = options
this.parent = ownOr(options, 'parent', null)
Expand Down Expand Up @@ -58,6 +60,9 @@ Base.prototype.passing = function () {
}

Base.prototype.setTimeout = function (n) {
if (!this.hrtime)
this.hrtime = process.hrtime()

if (!n) {
clearTimeout(this.timer)
this.timer = null
Expand Down Expand Up @@ -131,6 +136,11 @@ Base.prototype.onbail = function (reason) {
}

Base.prototype.oncomplete = function (results) {
if (this.hrtime) {
this.hrtime = process.hrtime(this.hrtime)
this.time = Math.round(this.hrtime[0] * 1e6 + this.hrtime[1] / 1e3) / 1e3
}

this.debug('ONCOMPLETE %j %j', this.name, results)
this.results = results
this.emit('complete', results)
Expand Down
1 change: 1 addition & 0 deletions lib/clean-yaml-object.js
Expand Up @@ -46,6 +46,7 @@ function yamlFilter (propertyName, isRoot, source, target) {
}

return !(propertyName === 'todo' ||
propertyName === 'time' ||
/^_?tapChild/.test(propertyName) ||
/^tapStream/.test(propertyName) ||
/^tapMochaTest/.test(propertyName) ||
Expand Down
3 changes: 2 additions & 1 deletion lib/point.js
Expand Up @@ -31,7 +31,8 @@ function tpMessage (message, extra) {
message += ' # TODO'
if (typeof extra.todo === 'string')
message += ' ' + extra.todo
}
} else if (extra.time)
message += ' # time=' + extra.time + 'ms'

var diagYaml = extra.diagnostic ? diags(extra) : ''
message += diagYaml
Expand Down
3 changes: 3 additions & 0 deletions lib/tap.js
Expand Up @@ -14,6 +14,7 @@ function TAP (options) {
var didPipe = false
TAP.prototype.pipe = function () {
didPipe = true
this.setTimeout(this.options.timeout)
this.pipe = Test.prototype.pipe
this.push = Test.prototype.push
return this.pipe.apply(this, arguments)
Expand All @@ -37,6 +38,8 @@ TAP.prototype.onbail = function () {
}

TAP.prototype.ondone = function () {
if (didPipe && this.time)
this.emit('data', '# time=' + this.time + 'ms\n')
this.emit('teardown')
}

Expand Down
4 changes: 4 additions & 0 deletions lib/test.js
Expand Up @@ -320,6 +320,8 @@ Test.prototype.onbufferedend = function (p, er) {
this.pool.remove(p)
p.options.tapChildBuffer = p.output || ''
p.options.stack = ''
if (p.time)
p.options.time = p.time
if (this.occupied === p)
this.occupied = null
if (er)
Expand All @@ -337,6 +339,8 @@ Test.prototype.onindentedend = function (p, er) {
this.subtests.splice(sti, 1)
p.readyToProcess = true
p.results = p.results || {}
if (p.time)
p.options.time = p.time
var to = p.options.timeout
if (to && p.passing())
var dur = Date.now() - p.start
Expand Down
2 changes: 1 addition & 1 deletion test/test/assert-at--bail--buffer.tap
@@ -1,5 +1,5 @@
TAP version 13
not ok 1 - foo {
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - baz
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}
Expand Down
2 changes: 1 addition & 1 deletion test/test/assert-at--buffer.tap
@@ -1,5 +1,5 @@
TAP version 13
not ok 1 - foo {
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - baz
---
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}
Expand Down
2 changes: 1 addition & 1 deletion test/test/assert-at.tap
Expand Up @@ -22,7 +22,7 @@ TAP version 13

1..4
# failed 4 of 4 tests
not ok 1 - foo
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~

1..1
# failed 1 test
Expand Down
2 changes: 1 addition & 1 deletion test/test/assert-todo-skip--bail--buffer.tap
@@ -1,5 +1,5 @@
TAP version 13
ok 1 - not much {
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - always passes # SKIP skip it good
not ok 2 - false # SKIP always fails
ok 3 - bonus # TODO remove todo directive
Expand Down
2 changes: 1 addition & 1 deletion test/test/assert-todo-skip--bail.tap
Expand Up @@ -19,7 +19,7 @@ TAP version 13
1..8
# todo: 4
# skip: 4
ok 1 - not much
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~

1..1

2 changes: 1 addition & 1 deletion test/test/assert-todo-skip--buffer.tap
@@ -1,5 +1,5 @@
TAP version 13
ok 1 - not much {
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - always passes # SKIP skip it good
not ok 2 - false # SKIP always fails
ok 3 - bonus # TODO remove todo directive
Expand Down
2 changes: 1 addition & 1 deletion test/test/assert-todo-skip.tap
Expand Up @@ -19,7 +19,7 @@ TAP version 13
1..8
# todo: 4
# skip: 4
ok 1 - not much
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~

1..1

4 changes: 2 additions & 2 deletions test/test/async--bail--buffer.tap
@@ -1,10 +1,10 @@
TAP version 13
ok 1 - first test {
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - this is ok
1..1
}

ok 2 - second test (async) {
ok 2 - second test (async) ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - this is ok
1..1
}
Expand Down
4 changes: 2 additions & 2 deletions test/test/async--bail.tap
Expand Up @@ -2,12 +2,12 @@ TAP version 13
# Subtest: first test
ok 1 - this is ok
1..1
ok 1 - first test
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~

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

1..2

4 changes: 2 additions & 2 deletions test/test/async--buffer.tap
@@ -1,10 +1,10 @@
TAP version 13
ok 1 - first test {
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - this is ok
1..1
}

ok 2 - second test (async) {
ok 2 - second test (async) ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - this is ok
1..1
}
Expand Down
4 changes: 2 additions & 2 deletions test/test/async.tap
Expand Up @@ -2,12 +2,12 @@ TAP version 13
# Subtest: first test
ok 1 - this is ok
1..1
ok 1 - first test
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~

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

1..2

4 changes: 2 additions & 2 deletions test/test/bail-child--bail--buffer.tap
@@ -1,6 +1,6 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - failer {
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - failer ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - this fails
---
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}
Expand Down
4 changes: 2 additions & 2 deletions test/test/bail-child--buffer.tap
@@ -1,6 +1,6 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - failer {
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - failer ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - this fails
---
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}
Expand Down
10 changes: 5 additions & 5 deletions test/test/bail-fail-spawn--bail--buffer.tap
@@ -1,19 +1,19 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js ___/# time=[0-9.]+(ms)?/~~~
---
{"args":["___/.*/~~~nesting.js"],"command":"___/.*(node|iojs)(.exe)?/~~~","cwd":"___/.*/~~~","exitCode":1}
...
{
not ok 1 - nesting {
not ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~ {
1..2
ok 1 - first {
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~ {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
}

not ok 2 - second {
not ok 2 - second ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - but that is ok
ok 2 - this passes
not ok 3 - nested failure
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-fail-spawn--bail.tap
Expand Up @@ -7,7 +7,7 @@ TAP version 13
1..2
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

# Subtest: second
ok 1 - but that is ok
Expand Down
10 changes: 5 additions & 5 deletions test/test/bail-fail-spawn--buffer.tap
@@ -1,19 +1,19 @@
TAP version 13
not ok 1 - bail fail {
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js ___/# time=[0-9.]+(ms)?/~~~
---
{"args":["___/.*/~~~nesting.js"],"command":"___/.*(node|iojs)(.exe)?/~~~","cwd":"___/.*/~~~","exitCode":1}
...
{
not ok 1 - nesting {
not ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~ {
1..2
ok 1 - first {
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~ {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
}

not ok 2 - second {
not ok 2 - second ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - but that is ok
ok 2 - this passes
not ok 3 - nested failure
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-fail-spawn.tap
Expand Up @@ -7,7 +7,7 @@ TAP version 13
1..2
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

# Subtest: second
ok 1 - but that is ok
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown--bail--buffer.tap
@@ -1,6 +1,6 @@
TAP version 13
ok 1 - this is fine
ok 2 - child {
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - child test point
1..1
}
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown--bail.tap
Expand Up @@ -3,7 +3,7 @@ ok 1 - this is fine
# Subtest: child
ok 1 - child test point
1..1
ok 2 - child
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~

Bail out! # i did not want to be torn down

2 changes: 1 addition & 1 deletion test/test/bail-teardown--buffer.tap
@@ -1,6 +1,6 @@
TAP version 13
ok 1 - this is fine
ok 2 - child {
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - child test point
1..1
}
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown-async--bail--buffer.tap
@@ -1,5 +1,5 @@
TAP version 13
ok 1 - foobar test {
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown-async--bail.tap
@@ -1,7 +1,7 @@
TAP version 13
# Subtest: foobar test
1..0
ok 1 - foobar test
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~

# Subtest: barfoo
Bail out! # teardown fail
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown-async--buffer.tap
@@ -1,5 +1,5 @@
TAP version 13
ok 1 - foobar test {
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown-async.tap
@@ -1,7 +1,7 @@
TAP version 13
# Subtest: foobar test
1..0
ok 1 - foobar test
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~

# Subtest: barfoo
Bail out! # teardown fail
Expand Down
2 changes: 1 addition & 1 deletion test/test/bail-teardown.tap
Expand Up @@ -3,7 +3,7 @@ ok 1 - this is fine
# Subtest: child
ok 1 - child test point
1..1
ok 2 - child
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~

Bail out! # i did not want to be torn down

6 changes: 3 additions & 3 deletions test/test/bailout--bail--buffer.tap
@@ -1,13 +1,13 @@
TAP version 13
ok 1 - nesting {
ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~ {
1..2
ok 1 - first {
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~ {
1..2
ok 1 - true is ok
ok 2 - doag is also okay
}

ok 2 - second {
ok 2 - second ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - but that is ok
ok 2 - this passes
1..2
Expand Down
6 changes: 3 additions & 3 deletions test/test/bailout--bail.tap
Expand Up @@ -5,15 +5,15 @@ TAP version 13
1..2
ok 1 - true is ok
ok 2 - doag is also okay
ok 1 - first
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~

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

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

ok 2 - this passes
not ok 3 - this fails
Expand Down

0 comments on commit f63ea3e

Please sign in to comment.