Skip to content

Commit f63ea3e

Browse files
committed
Put back the # time=... directives
1 parent 6a6faf0 commit f63ea3e

File tree

251 files changed

+832
-818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+832
-818
lines changed

lib/base.js

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ var ownOrEnv = require('own-or-env')
2121

2222
function Base (options) {
2323
this.start = 0
24+
this.hrtime = null
25+
this.time = null
2426
this.readyToProcess = false
2527
this.options = options
2628
this.parent = ownOr(options, 'parent', null)
@@ -58,6 +60,9 @@ Base.prototype.passing = function () {
5860
}
5961

6062
Base.prototype.setTimeout = function (n) {
63+
if (!this.hrtime)
64+
this.hrtime = process.hrtime()
65+
6166
if (!n) {
6267
clearTimeout(this.timer)
6368
this.timer = null
@@ -131,6 +136,11 @@ Base.prototype.onbail = function (reason) {
131136
}
132137

133138
Base.prototype.oncomplete = function (results) {
139+
if (this.hrtime) {
140+
this.hrtime = process.hrtime(this.hrtime)
141+
this.time = Math.round(this.hrtime[0] * 1e6 + this.hrtime[1] / 1e3) / 1e3
142+
}
143+
134144
this.debug('ONCOMPLETE %j %j', this.name, results)
135145
this.results = results
136146
this.emit('complete', results)

lib/clean-yaml-object.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function yamlFilter (propertyName, isRoot, source, target) {
4646
}
4747

4848
return !(propertyName === 'todo' ||
49+
propertyName === 'time' ||
4950
/^_?tapChild/.test(propertyName) ||
5051
/^tapStream/.test(propertyName) ||
5152
/^tapMochaTest/.test(propertyName) ||

lib/point.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function tpMessage (message, extra) {
3131
message += ' # TODO'
3232
if (typeof extra.todo === 'string')
3333
message += ' ' + extra.todo
34-
}
34+
} else if (extra.time)
35+
message += ' # time=' + extra.time + 'ms'
3536

3637
var diagYaml = extra.diagnostic ? diags(extra) : ''
3738
message += diagYaml

lib/tap.js

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function TAP (options) {
1414
var didPipe = false
1515
TAP.prototype.pipe = function () {
1616
didPipe = true
17+
this.setTimeout(this.options.timeout)
1718
this.pipe = Test.prototype.pipe
1819
this.push = Test.prototype.push
1920
return this.pipe.apply(this, arguments)
@@ -37,6 +38,8 @@ TAP.prototype.onbail = function () {
3738
}
3839

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

lib/test.js

+4
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ Test.prototype.onbufferedend = function (p, er) {
320320
this.pool.remove(p)
321321
p.options.tapChildBuffer = p.output || ''
322322
p.options.stack = ''
323+
if (p.time)
324+
p.options.time = p.time
323325
if (this.occupied === p)
324326
this.occupied = null
325327
if (er)
@@ -337,6 +339,8 @@ Test.prototype.onindentedend = function (p, er) {
337339
this.subtests.splice(sti, 1)
338340
p.readyToProcess = true
339341
p.results = p.results || {}
342+
if (p.time)
343+
p.options.time = p.time
340344
var to = p.options.timeout
341345
if (to && p.passing())
342346
var dur = Date.now() - p.start

test/test/assert-at--bail--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
not ok 1 - foo {
2+
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~ {
33
not ok 1 - baz
44
---
55
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}

test/test/assert-at--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
not ok 1 - foo {
2+
not ok 1 - foo ___/# time=[0-9.]+(ms)?/~~~ {
33
not ok 1 - baz
44
---
55
{"at":{"column":3,"file":"test/test/assert-at.js","function":"baz","line":14},"source":"blo(t)\n"}

test/test/assert-at.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ TAP version 13
2222

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

2727
1..1
2828
# failed 1 test

test/test/assert-todo-skip--bail--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
ok 1 - not much {
2+
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~ {
33
ok 1 - always passes # SKIP skip it good
44
not ok 2 - false # SKIP always fails
55
ok 3 - bonus # TODO remove todo directive

test/test/assert-todo-skip--bail.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TAP version 13
1919
1..8
2020
# todo: 4
2121
# skip: 4
22-
ok 1 - not much
22+
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~
2323

2424
1..1
2525

test/test/assert-todo-skip--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
ok 1 - not much {
2+
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~ {
33
ok 1 - always passes # SKIP skip it good
44
not ok 2 - false # SKIP always fails
55
ok 3 - bonus # TODO remove todo directive

test/test/assert-todo-skip.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TAP version 13
1919
1..8
2020
# todo: 4
2121
# skip: 4
22-
ok 1 - not much
22+
ok 1 - not much ___/# time=[0-9.]+(ms)?/~~~
2323

2424
1..1
2525

test/test/async--bail--buffer.tap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
TAP version 13
2-
ok 1 - first test {
2+
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~ {
33
ok 1 - this is ok
44
1..1
55
}
66

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

test/test/async--bail.tap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ TAP version 13
22
# Subtest: first test
33
ok 1 - this is ok
44
1..1
5-
ok 1 - first test
5+
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~
66

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

1212
1..2
1313

test/test/async--buffer.tap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
TAP version 13
2-
ok 1 - first test {
2+
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~ {
33
ok 1 - this is ok
44
1..1
55
}
66

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

test/test/async.tap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ TAP version 13
22
# Subtest: first test
33
ok 1 - this is ok
44
1..1
5-
ok 1 - first test
5+
ok 1 - first test ___/# time=[0-9.]+(ms)?/~~~
66

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

1212
1..2
1313

test/test/bail-child--bail--buffer.tap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TAP version 13
2-
not ok 1 - bail fail {
3-
not ok 1 - failer {
2+
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
3+
not ok 1 - failer ___/# time=[0-9.]+(ms)?/~~~ {
44
not ok 1 - this fails
55
---
66
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}

test/test/bail-child--buffer.tap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TAP version 13
2-
not ok 1 - bail fail {
3-
not ok 1 - failer {
2+
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
3+
not ok 1 - failer ___/# time=[0-9.]+(ms)?/~~~ {
44
not ok 1 - this fails
55
---
66
{"at":{"column":7,"file":"test/test/bail-child.js","line":7},"source":"t.fail('this fails')\n"}

test/test/bail-fail-spawn--bail--buffer.tap

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
TAP version 13
2-
not ok 1 - bail fail {
3-
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js
2+
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
3+
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js ___/# time=[0-9.]+(ms)?/~~~
44
---
55
{"args":["___/.*/~~~nesting.js"],"command":"___/.*(node|iojs)(.exe)?/~~~","cwd":"___/.*/~~~","exitCode":1}
66
...
77
{
8-
not ok 1 - nesting {
8+
not ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~ {
99
1..2
10-
ok 1 - first {
10+
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~ {
1111
1..2
1212
ok 1 - true is ok
1313
ok 2 - doag is also okay
1414
}
1515

16-
not ok 2 - second {
16+
not ok 2 - second ___/# time=[0-9.]+(ms)?/~~~ {
1717
ok 1 - but that is ok
1818
ok 2 - this passes
1919
not ok 3 - nested failure

test/test/bail-fail-spawn--bail.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TAP version 13
77
1..2
88
ok 1 - true is ok
99
ok 2 - doag is also okay
10-
ok 1 - first
10+
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~
1111

1212
# Subtest: second
1313
ok 1 - but that is ok

test/test/bail-fail-spawn--buffer.tap

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
TAP version 13
2-
not ok 1 - bail fail {
3-
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js
2+
not ok 1 - bail fail ___/# time=[0-9.]+(ms)?/~~~ {
3+
not ok 1 - ___/.*(node|iojs)(.exe)?/~~~ ./test/test/nesting.js ___/# time=[0-9.]+(ms)?/~~~
44
---
55
{"args":["___/.*/~~~nesting.js"],"command":"___/.*(node|iojs)(.exe)?/~~~","cwd":"___/.*/~~~","exitCode":1}
66
...
77
{
8-
not ok 1 - nesting {
8+
not ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~ {
99
1..2
10-
ok 1 - first {
10+
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~ {
1111
1..2
1212
ok 1 - true is ok
1313
ok 2 - doag is also okay
1414
}
1515

16-
not ok 2 - second {
16+
not ok 2 - second ___/# time=[0-9.]+(ms)?/~~~ {
1717
ok 1 - but that is ok
1818
ok 2 - this passes
1919
not ok 3 - nested failure

test/test/bail-fail-spawn.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TAP version 13
77
1..2
88
ok 1 - true is ok
99
ok 2 - doag is also okay
10-
ok 1 - first
10+
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~
1111

1212
# Subtest: second
1313
ok 1 - but that is ok

test/test/bail-teardown--bail--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TAP version 13
22
ok 1 - this is fine
3-
ok 2 - child {
3+
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~ {
44
ok 1 - child test point
55
1..1
66
}

test/test/bail-teardown--bail.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ok 1 - this is fine
33
# Subtest: child
44
ok 1 - child test point
55
1..1
6-
ok 2 - child
6+
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~
77

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

test/test/bail-teardown--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TAP version 13
22
ok 1 - this is fine
3-
ok 2 - child {
3+
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~ {
44
ok 1 - child test point
55
1..1
66
}

test/test/bail-teardown-async--bail--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
ok 1 - foobar test {
2+
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~ {
33
1..0
44
}
55

test/test/bail-teardown-async--bail.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TAP version 13
22
# Subtest: foobar test
33
1..0
4-
ok 1 - foobar test
4+
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~
55

66
# Subtest: barfoo
77
Bail out! # teardown fail

test/test/bail-teardown-async--buffer.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAP version 13
2-
ok 1 - foobar test {
2+
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~ {
33
1..0
44
}
55

test/test/bail-teardown-async.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TAP version 13
22
# Subtest: foobar test
33
1..0
4-
ok 1 - foobar test
4+
ok 1 - foobar test ___/# time=[0-9.]+(ms)?/~~~
55

66
# Subtest: barfoo
77
Bail out! # teardown fail

test/test/bail-teardown.tap

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ok 1 - this is fine
33
# Subtest: child
44
ok 1 - child test point
55
1..1
6-
ok 2 - child
6+
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~
77

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

test/test/bailout--bail--buffer.tap

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
TAP version 13
2-
ok 1 - nesting {
2+
ok 1 - nesting ___/# time=[0-9.]+(ms)?/~~~ {
33
1..2
4-
ok 1 - first {
4+
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~ {
55
1..2
66
ok 1 - true is ok
77
ok 2 - doag is also okay
88
}
99

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

test/test/bailout--bail.tap

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ TAP version 13
55
1..2
66
ok 1 - true is ok
77
ok 2 - doag is also okay
8-
ok 1 - first
8+
ok 1 - first ___/# time=[0-9.]+(ms)?/~~~
99

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

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

1818
ok 2 - this passes
1919
not ok 3 - this fails

0 commit comments

Comments
 (0)