Skip to content

Commit 028eee2

Browse files
committed
Don't put unfiltered stack traces in output tests
not cross-node-version friendly
1 parent 1e1cf7d commit 028eee2

6 files changed

+20
-75
lines changed

scripts/generate-test-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ function generate (file, bail, buffer) {
5252
var timere = new RegExp(timep, 'g')
5353
output = output.replace(timere, '___/' + timep + '/~~~')
5454

55-
// strip out un-pretty-ified error stack lines
55+
// raw stack traces vary in depth between node versions, and always
56+
// cause problems. Replace them with an obvious failure.
5657
output = output.replace(
5758
/^ at .*?:[0-9]+:[0-9]+\)?$/mg,
58-
'___/^ at .*?:[0-9]+:[0-9]+\\)?$/~~~')
59+
'ERROR: stacks will cause problems, please fix this in the test')
5960

6061
output = output.split(file).join('___/.*/~~~' + path.basename(file))
6162
output = output.split(f).join('___/.*/~~~' + path.basename(f))

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,13 @@ TAP version 13
22
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~ {
33
not ok 1 - test unfinished
44
---
5-
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
5+
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
66
...
77

88
Bail out! # test unfinished
99
}
1010
Bail out! # test unfinished
1111
Error: TAP teardown
12-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
13-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
14-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
15-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
16-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
17-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
18-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
19-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
20-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
21-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
22-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
23-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
24-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
25-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
26-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
27-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
12+
>>some stack junk<<
2813
{ name: 'TAP', autoend: true, test: 'TAP' }
2914

test/test/teardown-throw-autocomplete--bail.tap

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,12 @@ TAP version 13
22
# Subtest: child
33
not ok 1 - test unfinished
44
---
5-
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
5+
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
66
...
77

88
Bail out! # test unfinished
99
Bail out! # test unfinished
1010
Error: TAP teardown
11-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
12-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
13-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
14-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
15-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
16-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
17-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
18-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
19-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
20-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
21-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
22-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
23-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
24-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
25-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
26-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
11+
>>some stack junk<<
2712
{ name: 'TAP', autoend: true, test: 'TAP' }
2813

test/test/teardown-throw-autocomplete--buffer.tap

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ TAP version 13
22
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~ {
33
not ok 1 - test unfinished
44
---
5-
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
5+
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
66
...
77

88
not ok 2 - afterEach
99
---
10-
{"at":{"column":9,"file":"test/test/teardown-throw-autocomplete.js","line":7},"source":"throw new Error('afterEach')\n","test":"child"}
10+
{"at":{"column":9,"file":"test/test/teardown-throw-autocomplete.js","line":11},"source":"throw new Error('afterEach')\n","test":"child"}
1111
...
1212

1313
1..2
@@ -16,28 +16,13 @@ not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~ {
1616

1717
not ok 2 - child teardown
1818
---
19-
{"at":{"column":11,"file":"test/test/teardown-throw-autocomplete.js","line":12},"source":"throw new Error('child teardown')\n","test":"child"}
19+
{"at":{"column":11,"file":"test/test/teardown-throw-autocomplete.js","line":16},"source":"throw new Error('child teardown')\n","test":"child"}
2020
...
2121

2222
1..2
2323
# failed 2 of 2 tests
2424
___/# time=[0-9.]+(ms)?/~~~
2525
Error: TAP teardown
26-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
27-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
28-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
29-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
30-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
31-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
32-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
33-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
34-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
35-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
36-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
37-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
38-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
39-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
40-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
41-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
26+
>>some stack junk<<
4227
{ name: 'TAP', autoend: true, test: 'TAP' }
4328

test/test/teardown-throw-autocomplete.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
console.error = console.log
1+
console.error = function (msg) {
2+
return (/^ at /.test(msg))
3+
? console.log('>>some stack junk<<')
4+
: console.log.apply(this, arguments)
5+
}
26
var t = require('../..')
37
t.tearDown(function () {
48
throw new Error('TAP teardown')

test/test/teardown-throw-autocomplete.tap

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ TAP version 13
22
# Subtest: child
33
not ok 1 - test unfinished
44
---
5-
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
5+
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
66
...
77

88
not ok 2 - afterEach
99
---
10-
{"at":{"column":9,"file":"test/test/teardown-throw-autocomplete.js","line":7},"source":"throw new Error('afterEach')\n","test":"child"}
10+
{"at":{"column":9,"file":"test/test/teardown-throw-autocomplete.js","line":11},"source":"throw new Error('afterEach')\n","test":"child"}
1111
...
1212

1313
1..2
@@ -16,28 +16,13 @@ not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~
1616

1717
not ok 2 - child teardown
1818
---
19-
{"at":{"column":11,"file":"test/test/teardown-throw-autocomplete.js","line":12},"source":"throw new Error('child teardown')\n","test":"child"}
19+
{"at":{"column":11,"file":"test/test/teardown-throw-autocomplete.js","line":16},"source":"throw new Error('child teardown')\n","test":"child"}
2020
...
2121

2222
1..2
2323
# failed 2 of 2 tests
2424
___/# time=[0-9.]+(ms)?/~~~
2525
Error: TAP teardown
26-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
27-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
28-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
29-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
30-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
31-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
32-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
33-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
34-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
35-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
36-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
37-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
38-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
39-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
40-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
41-
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
26+
>>some stack junk<<
4227
{ name: 'TAP', autoend: true, test: 'TAP' }
4328

0 commit comments

Comments
 (0)