Skip to content

Commit

Permalink
add test case demonstrating odd teardown timing
Browse files Browse the repository at this point in the history
Re #353
  • Loading branch information
isaacs committed Feb 27, 2017
1 parent 0e16fae commit 67b03a9
Show file tree
Hide file tree
Showing 10 changed files with 343 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test/teardown-timing--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TAP version 13
############## step1 startup
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step1 teardown
############## step2 startup
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step2 teardown
############## step3 startup
############## step4 startup
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step3 teardown
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

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

28 changes: 28 additions & 0 deletions test/test/teardown-timing--bail.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TAP version 13
############## step1 startup
# Subtest: step1
1..0
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~

############## step2 startup
############## step1 teardown
# Subtest: step2
1..0
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~

############## step3 startup
# Subtest: step3
1..0
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~

############## step3 teardown
############## step4 startup
# Subtest: step4
1..0
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~

############## step4 teardown
############## step2 teardown
1..4
___/# time=[0-9.]+(ms)?/~~~

28 changes: 28 additions & 0 deletions test/test/teardown-timing--buffer.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TAP version 13
############## step1 startup
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step1 teardown
############## step2 startup
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step2 teardown
############## step3 startup
############## step4 startup
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step3 teardown
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

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

32 changes: 32 additions & 0 deletions test/test/teardown-timing-throws--bail--buffer.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
TAP version 13
############## step1 startup
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step1 teardown
############## step2 startup
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step2 teardown
############## step3 startup
############## step4 startup
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step3 teardown
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step4 teardown
not ok 5 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

Bail out! # ############## step1 teardown

31 changes: 31 additions & 0 deletions test/test/teardown-timing-throws--bail.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
TAP version 13
############## step1 startup
# Subtest: step1
1..0
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~

############## step2 startup
############## step1 teardown
# Subtest: step2
1..0
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~

############## step3 startup
# Subtest: step3
1..0
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~

############## step3 teardown
############## step4 startup
# Subtest: step4
1..0
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~

############## step4 teardown
not ok 5 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

Bail out! # ############## step1 teardown

49 changes: 49 additions & 0 deletions test/test/teardown-timing-throws--buffer.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
TAP version 13
############## step1 startup
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step1 teardown
############## step2 startup
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step2 teardown
############## step3 startup
############## step4 startup
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step3 teardown
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
1..0
}

############## step4 teardown
not ok 5 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

not ok 6 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":16},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

not ok 7 - ############## step3 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":25},"source":"throw new Error('############## step3 teardown')\n","test":"TAP"}
...

not ok 8 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":34},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

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

37 changes: 37 additions & 0 deletions test/test/teardown-timing-throws.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var t = require('../..')

t.test('step1', function (t) {
console.log('##############', 'step1 startup')
t.tearDown(function () {
console.log('############## step1 teardown')
throw new Error('############## step1 teardown')
})
setImmediate(t.done)
})

t.test('step2', function (t) {
console.log('##############', 'step2 startup')
t.tearDown(function () {
console.log('############## step2 teardown')
throw new Error('############## step1 teardown')
})
setImmediate(t.done)
})

t.test('step3', function (t) {
console.log('##############', 'step3 startup')
t.tearDown(function () {
console.log('############## step3 teardown')
throw new Error('############## step3 teardown')
})
t.done()
})

t.test('step4', function (t) {
console.log('##############', 'step4 startup')
t.tearDown(function () {
console.log('############## step4 teardown')
throw new Error('############## step1 teardown')
})
t.done()
})
49 changes: 49 additions & 0 deletions test/test/teardown-timing-throws.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
TAP version 13
############## step1 startup
# Subtest: step1
1..0
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~

############## step2 startup
############## step1 teardown
# Subtest: step2
1..0
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~

############## step3 startup
# Subtest: step3
1..0
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~

############## step3 teardown
############## step4 startup
# Subtest: step4
1..0
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~

############## step4 teardown
not ok 5 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

not ok 6 - ############## step3 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":25},"source":"throw new Error('############## step3 teardown')\n","test":"TAP"}
...

not ok 7 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":34},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

############## step2 teardown
not ok 8 - ############## step1 teardown
---
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":16},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
...

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

33 changes: 33 additions & 0 deletions test/test/teardown-timing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var t = require('../..')

t.test('step1', function (t) {
console.log('##############', 'step1 startup')
t.tearDown(function () {
console.log('##############', 'step1 teardown')
})
setImmediate(t.done)
})

t.test('step2', function (t) {
console.log('##############', 'step2 startup')
t.tearDown(function () {
console.log('##############', 'step2 teardown')
})
setImmediate(t.done)
})

t.test('step3', function (t) {
console.log('##############', 'step3 startup')
t.tearDown(function () {
console.log('##############', 'step3 teardown')
})
t.done()
})

t.test('step4', function (t) {
console.log('##############', 'step4 startup')
t.tearDown(function () {
console.log('##############', 'step4 teardown')
})
t.done()
})
28 changes: 28 additions & 0 deletions test/test/teardown-timing.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TAP version 13
############## step1 startup
# Subtest: step1
1..0
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~

############## step2 startup
############## step1 teardown
# Subtest: step2
1..0
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~

############## step3 startup
# Subtest: step3
1..0
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~

############## step3 teardown
############## step4 startup
# Subtest: step4
1..0
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~

############## step4 teardown
############## step2 teardown
1..4
___/# time=[0-9.]+(ms)?/~~~

0 comments on commit 67b03a9

Please sign in to comment.