Skip to content

Commit 67b03a9

Browse files
committed
add test case demonstrating odd teardown timing
Re #353
1 parent 0e16fae commit 67b03a9

10 files changed

+343
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
TAP version 13
2+
############## step1 startup
3+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
4+
1..0
5+
}
6+
7+
############## step1 teardown
8+
############## step2 startup
9+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
10+
1..0
11+
}
12+
13+
############## step2 teardown
14+
############## step3 startup
15+
############## step4 startup
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
17+
1..0
18+
}
19+
20+
############## step3 teardown
21+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
22+
1..0
23+
}
24+
25+
############## step4 teardown
26+
1..4
27+
___/# time=[0-9.]+(ms)?/~~~
28+

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
TAP version 13
2+
############## step1 startup
3+
# Subtest: step1
4+
1..0
5+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~
6+
7+
############## step2 startup
8+
############## step1 teardown
9+
# Subtest: step2
10+
1..0
11+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~
12+
13+
############## step3 startup
14+
# Subtest: step3
15+
1..0
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~
17+
18+
############## step3 teardown
19+
############## step4 startup
20+
# Subtest: step4
21+
1..0
22+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~
23+
24+
############## step4 teardown
25+
############## step2 teardown
26+
1..4
27+
___/# time=[0-9.]+(ms)?/~~~
28+

test/test/teardown-timing--buffer.tap

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
TAP version 13
2+
############## step1 startup
3+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
4+
1..0
5+
}
6+
7+
############## step1 teardown
8+
############## step2 startup
9+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
10+
1..0
11+
}
12+
13+
############## step2 teardown
14+
############## step3 startup
15+
############## step4 startup
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
17+
1..0
18+
}
19+
20+
############## step3 teardown
21+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
22+
1..0
23+
}
24+
25+
############## step4 teardown
26+
1..4
27+
___/# time=[0-9.]+(ms)?/~~~
28+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
TAP version 13
2+
############## step1 startup
3+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
4+
1..0
5+
}
6+
7+
############## step1 teardown
8+
############## step2 startup
9+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
10+
1..0
11+
}
12+
13+
############## step2 teardown
14+
############## step3 startup
15+
############## step4 startup
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
17+
1..0
18+
}
19+
20+
############## step3 teardown
21+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
22+
1..0
23+
}
24+
25+
############## step4 teardown
26+
not ok 5 - ############## step1 teardown
27+
---
28+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
29+
...
30+
31+
Bail out! # ############## step1 teardown
32+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
TAP version 13
2+
############## step1 startup
3+
# Subtest: step1
4+
1..0
5+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~
6+
7+
############## step2 startup
8+
############## step1 teardown
9+
# Subtest: step2
10+
1..0
11+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~
12+
13+
############## step3 startup
14+
# Subtest: step3
15+
1..0
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~
17+
18+
############## step3 teardown
19+
############## step4 startup
20+
# Subtest: step4
21+
1..0
22+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~
23+
24+
############## step4 teardown
25+
not ok 5 - ############## step1 teardown
26+
---
27+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
28+
...
29+
30+
Bail out! # ############## step1 teardown
31+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
TAP version 13
2+
############## step1 startup
3+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~ {
4+
1..0
5+
}
6+
7+
############## step1 teardown
8+
############## step2 startup
9+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~ {
10+
1..0
11+
}
12+
13+
############## step2 teardown
14+
############## step3 startup
15+
############## step4 startup
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~ {
17+
1..0
18+
}
19+
20+
############## step3 teardown
21+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~ {
22+
1..0
23+
}
24+
25+
############## step4 teardown
26+
not ok 5 - ############## step1 teardown
27+
---
28+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
29+
...
30+
31+
not ok 6 - ############## step1 teardown
32+
---
33+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":16},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
34+
...
35+
36+
not ok 7 - ############## step3 teardown
37+
---
38+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":25},"source":"throw new Error('############## step3 teardown')\n","test":"TAP"}
39+
...
40+
41+
not ok 8 - ############## step1 teardown
42+
---
43+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":34},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
44+
...
45+
46+
1..8
47+
# failed 4 of 8 tests
48+
___/# time=[0-9.]+(ms)?/~~~
49+

test/test/teardown-timing-throws.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var t = require('../..')
2+
3+
t.test('step1', function (t) {
4+
console.log('##############', 'step1 startup')
5+
t.tearDown(function () {
6+
console.log('############## step1 teardown')
7+
throw new Error('############## step1 teardown')
8+
})
9+
setImmediate(t.done)
10+
})
11+
12+
t.test('step2', function (t) {
13+
console.log('##############', 'step2 startup')
14+
t.tearDown(function () {
15+
console.log('############## step2 teardown')
16+
throw new Error('############## step1 teardown')
17+
})
18+
setImmediate(t.done)
19+
})
20+
21+
t.test('step3', function (t) {
22+
console.log('##############', 'step3 startup')
23+
t.tearDown(function () {
24+
console.log('############## step3 teardown')
25+
throw new Error('############## step3 teardown')
26+
})
27+
t.done()
28+
})
29+
30+
t.test('step4', function (t) {
31+
console.log('##############', 'step4 startup')
32+
t.tearDown(function () {
33+
console.log('############## step4 teardown')
34+
throw new Error('############## step1 teardown')
35+
})
36+
t.done()
37+
})

test/test/teardown-timing-throws.tap

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
TAP version 13
2+
############## step1 startup
3+
# Subtest: step1
4+
1..0
5+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~
6+
7+
############## step2 startup
8+
############## step1 teardown
9+
# Subtest: step2
10+
1..0
11+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~
12+
13+
############## step3 startup
14+
# Subtest: step3
15+
1..0
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~
17+
18+
############## step3 teardown
19+
############## step4 startup
20+
# Subtest: step4
21+
1..0
22+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~
23+
24+
############## step4 teardown
25+
not ok 5 - ############## step1 teardown
26+
---
27+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":7},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
28+
...
29+
30+
not ok 6 - ############## step3 teardown
31+
---
32+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":25},"source":"throw new Error('############## step3 teardown')\n","test":"TAP"}
33+
...
34+
35+
not ok 7 - ############## step1 teardown
36+
---
37+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":34},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
38+
...
39+
40+
############## step2 teardown
41+
not ok 8 - ############## step1 teardown
42+
---
43+
{"at":{"column":11,"file":"test/test/teardown-timing-throws.js","line":16},"source":"throw new Error('############## step1 teardown')\n","test":"TAP"}
44+
...
45+
46+
1..8
47+
# failed 4 of 8 tests
48+
___/# time=[0-9.]+(ms)?/~~~
49+

test/test/teardown-timing.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var t = require('../..')
2+
3+
t.test('step1', function (t) {
4+
console.log('##############', 'step1 startup')
5+
t.tearDown(function () {
6+
console.log('##############', 'step1 teardown')
7+
})
8+
setImmediate(t.done)
9+
})
10+
11+
t.test('step2', function (t) {
12+
console.log('##############', 'step2 startup')
13+
t.tearDown(function () {
14+
console.log('##############', 'step2 teardown')
15+
})
16+
setImmediate(t.done)
17+
})
18+
19+
t.test('step3', function (t) {
20+
console.log('##############', 'step3 startup')
21+
t.tearDown(function () {
22+
console.log('##############', 'step3 teardown')
23+
})
24+
t.done()
25+
})
26+
27+
t.test('step4', function (t) {
28+
console.log('##############', 'step4 startup')
29+
t.tearDown(function () {
30+
console.log('##############', 'step4 teardown')
31+
})
32+
t.done()
33+
})

test/test/teardown-timing.tap

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
TAP version 13
2+
############## step1 startup
3+
# Subtest: step1
4+
1..0
5+
ok 1 - step1 ___/# time=[0-9.]+(ms)?/~~~
6+
7+
############## step2 startup
8+
############## step1 teardown
9+
# Subtest: step2
10+
1..0
11+
ok 2 - step2 ___/# time=[0-9.]+(ms)?/~~~
12+
13+
############## step3 startup
14+
# Subtest: step3
15+
1..0
16+
ok 3 - step3 ___/# time=[0-9.]+(ms)?/~~~
17+
18+
############## step3 teardown
19+
############## step4 startup
20+
# Subtest: step4
21+
1..0
22+
ok 4 - step4 ___/# time=[0-9.]+(ms)?/~~~
23+
24+
############## step4 teardown
25+
############## step2 teardown
26+
1..4
27+
___/# time=[0-9.]+(ms)?/~~~
28+

0 commit comments

Comments
 (0)