Skip to content

Commit

Permalink
Don't put unfiltered stack traces in output tests
Browse files Browse the repository at this point in the history
not cross-node-version friendly
  • Loading branch information
isaacs committed Mar 2, 2017
1 parent 1e1cf7d commit 028eee2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 75 deletions.
5 changes: 3 additions & 2 deletions scripts/generate-test-test.js
Expand Up @@ -52,10 +52,11 @@ function generate (file, bail, buffer) {
var timere = new RegExp(timep, 'g')
output = output.replace(timere, '___/' + timep + '/~~~')

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

output = output.split(file).join('___/.*/~~~' + path.basename(file))
output = output.split(f).join('___/.*/~~~' + path.basename(f))
Expand Down
19 changes: 2 additions & 17 deletions test/test/teardown-throw-autocomplete--bail--buffer.tap
Expand Up @@ -2,28 +2,13 @@ TAP version 13
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - test unfinished
---
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
...

Bail out! # test unfinished
}
Bail out! # test unfinished
Error: TAP teardown
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
>>some stack junk<<
{ name: 'TAP', autoend: true, test: 'TAP' }

19 changes: 2 additions & 17 deletions test/test/teardown-throw-autocomplete--bail.tap
Expand Up @@ -2,27 +2,12 @@ TAP version 13
# Subtest: child
not ok 1 - test unfinished
---
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
...

Bail out! # test unfinished
Bail out! # test unfinished
Error: TAP teardown
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
>>some stack junk<<
{ name: 'TAP', autoend: true, test: 'TAP' }

23 changes: 4 additions & 19 deletions test/test/teardown-throw-autocomplete--buffer.tap
Expand Up @@ -2,12 +2,12 @@ TAP version 13
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~ {
not ok 1 - test unfinished
---
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
...

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

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

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

1..2
# failed 2 of 2 tests
___/# time=[0-9.]+(ms)?/~~~
Error: TAP teardown
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
>>some stack junk<<
{ name: 'TAP', autoend: true, test: 'TAP' }

6 changes: 5 additions & 1 deletion test/test/teardown-throw-autocomplete.js
@@ -1,4 +1,8 @@
console.error = console.log
console.error = function (msg) {
return (/^ at /.test(msg))
? console.log('>>some stack junk<<')
: console.log.apply(this, arguments)
}
var t = require('../..')
t.tearDown(function () {
throw new Error('TAP teardown')
Expand Down
23 changes: 4 additions & 19 deletions test/test/teardown-throw-autocomplete.tap
Expand Up @@ -2,12 +2,12 @@ TAP version 13
# Subtest: child
not ok 1 - test unfinished
---
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":10},"source":"t.test('child', function (t) {\n","test":"child"}
{"at":{"column":3,"file":"test/test/teardown-throw-autocomplete.js","line":14},"source":"t.test('child', function (t) {\n","test":"child"}
...

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

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

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

1..2
# failed 2 of 2 tests
___/# time=[0-9.]+(ms)?/~~~
Error: TAP teardown
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
___/^ at .*?:[0-9]+:[0-9]+\)?$/~~~
>>some stack junk<<
{ name: 'TAP', autoend: true, test: 'TAP' }

0 comments on commit 028eee2

Please sign in to comment.