[Pkg-javascript-commits] [node-tap] 91/186: Clean up tests to pass on node v4

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 16:40:47 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-tap.

commit a21d6e8040f1b24e94dc53b7a01843fc766009a8
Author: isaacs <i at izs.me>
Date:   Wed Nov 15 14:05:43 2017 -0800

    Clean up tests to pass on node v4
---
 tap-snapshots/test-run.js-TAP.test.js   |   2 +-
 tap-snapshots/test-spawn.js-TAP.test.js |  15 +-
 tap-snapshots/test-tap.js-TAP.test.js   |  91 ++++----
 tap-snapshots/test-test.js-TAP.test.js  | 395 ++++++++++++++------------------
 test/clean-stacks.js                    |  53 +++++
 test/run.js                             |  24 +-
 test/spawn.js                           |  12 +-
 test/tap.js                             |  24 +-
 test/test.js                            |  18 +-
 9 files changed, 290 insertions(+), 344 deletions(-)

diff --git a/tap-snapshots/test-run.js-TAP.test.js b/tap-snapshots/test-run.js-TAP.test.js
index 277bb22..418bab2 100644
--- a/tap-snapshots/test-run.js-TAP.test.js
+++ b/tap-snapshots/test-run.js-TAP.test.js
@@ -14,7 +14,7 @@ ok 1 - test/cli-tests/ok.js # {time}
 
 exports[`test/run.js TAP stdin with file > undefined 1`] = `
 TAP version 13
-ok 1 - foo.js # {time} {
+ok 1 - test/cli-tests/foo.test.js # {time} {
     ok 1 - child # {time} {
         ok 1 - this is fine
         1..1
diff --git a/tap-snapshots/test-spawn.js-TAP.test.js b/tap-snapshots/test-spawn.js-TAP.test.js
index 99aa82e..d83d1c2 100644
--- a/tap-snapshots/test-spawn.js-TAP.test.js
+++ b/tap-snapshots/test-spawn.js-TAP.test.js
@@ -37,23 +37,22 @@ exports[`test/spawn.js TAP failure to spawn > undefined 1`] = `
 
 not ok 1 - spawn something that does not exist ENOENT
   ---
-  command: something that does not exist
   args: []
-  stdio:
-    - 0
-    - pipe
-    - 2
-  cwd: {CWD}
   at:
     line: #
     column: #
     file: util.js
-    function: _errnoException
   code: ENOENT
+  command: something that does not exist
+  cwd: {CWD}
   errno: ENOENT
-  syscall: spawn something that does not exist
   path: something that does not exist
   spawnargs: []
+  stdio:
+    - 0
+    - pipe
+    - 2
+  syscall: spawn something that does not exist
   test: 'something that does not exist '
   ...
 1..1
diff --git a/tap-snapshots/test-tap.js-TAP.test.js b/tap-snapshots/test-tap.js-TAP.test.js
index e8af938..584e2d0 100644
--- a/tap-snapshots/test-tap.js-TAP.test.js
+++ b/tap-snapshots/test-tap.js-TAP.test.js
@@ -27,11 +27,10 @@ not ok 1 - expected
     line: #
     column: #
     file: test/tap.js
-    function: notOk
-  stack: |
-    {STACK}
   source: |
     notOk: t => t.fail('expected'),
+  stack: |
+    {STACK}
   ...
 
 1..1
@@ -155,12 +154,11 @@ not ok 2 - broken
     line: #
     column: #
     file: test/tap.js
-    function: unhandled promise
+  source: |
+    Promise.reject(new Error('broken'))
   stack: |
     {STACK}
   test: TAP
-  source: |
-    Promise.reject(new Error('broken'))
   ...
 
 1..2
@@ -221,11 +219,10 @@ not ok 1 - v0.10.420
     line: #
     column: #
     file: test/tap.js
-    function: process.exitCode polyfill
-  stack: |
-    {STACK}
   source: |
     t.fail(process.version)
+  stack: |
+    {STACK}
   ...
 
 1..1
@@ -251,24 +248,24 @@ TAP version 13
 `
 
 exports[`test/tap.js TAP TAP_DEBUG=1 > stderr 1`] = `
-TAP {PID} TAP: PROCESSING(TAP) 2
-TAP {PID} TAP: > STRING
-TAP {PID} TAP: LINE "TAP version 13\\n"
-TAP {PID} TAP: < already processing
-TAP {PID} TAP: > STRING
-TAP {PID} TAP: LINE "# this is fine\\n"
-TAP {PID} TAP: done processing [] false
-TAP {PID} TAP: PROCESSING(TAP) 1
-TAP {PID} TAP: > METHOD
-TAP {PID} TAP: END implicit=true
-TAP {PID} TAP: END(TAP) implicit plan 0
-TAP {PID} TAP: END implicit=true
-TAP {PID} TAP: < already processing
-TAP {PID} TAP: > STRING
-TAP {PID} TAP: LINE "1..0\\n"
-TAP {PID} TAP: > EOF TAP
-TAP {PID} TAP: ONCOMPLETE "TAP" {"ok":true,"count":0,"pass":0,"fail":0,"bailout":false,"todo":0,"skip":0,"plan":{"start":1,"end":0,"skipAll":true,"skipReason":"","comment":""},"failures":[]}
-TAP {PID} TAP: done processing [] false
+TAP {pid} TAP: PROCESSING(TAP) 2
+TAP {pid} TAP: > STRING
+TAP {pid} TAP: LINE "TAP version 13\\n"
+TAP {pid} TAP: < already processing
+TAP {pid} TAP: > STRING
+TAP {pid} TAP: LINE "# this is fine\\n"
+TAP {pid} TAP: done processing [] false
+TAP {pid} TAP: PROCESSING(TAP) 1
+TAP {pid} TAP: > METHOD
+TAP {pid} TAP: END implicit=true
+TAP {pid} TAP: END(TAP) implicit plan 0
+TAP {pid} TAP: END implicit=true
+TAP {pid} TAP: < already processing
+TAP {pid} TAP: > STRING
+TAP {pid} TAP: LINE "1..0\\n"
+TAP {pid} TAP: > EOF TAP
+TAP {pid} TAP: ONCOMPLETE "TAP" {"ok":true,"count":0,"pass":0,"fail":0,"bailout":false,"todo":0,"skip":0,"plan":{"start":1,"end":0,"skipAll":true,"skipReason":"","comment":""},"failures":[]}
+TAP {pid} TAP: done processing [] false
 
 `
 
@@ -284,19 +281,19 @@ TAP version 13
 `
 
 exports[`test/tap.js TAP NODE_DEBUG=tap > stderr 1`] = `
-TAP {PID} TAP: END implicit=true
-TAP {PID} TAP: PROCESSING(TAP) 3
-TAP {PID} TAP: > STRING
-TAP {PID} TAP: LINE "TAP version 13\\n"
-TAP {PID} TAP: < already processing
-TAP {PID} TAP: > STRING
-TAP {PID} TAP: LINE "1..0\\n"
-TAP {PID} TAP: > METHOD
-TAP {PID} TAP: END implicit=true
-TAP {PID} TAP: < already processing
-TAP {PID} TAP: > EOF TAP
-TAP {PID} TAP: ONCOMPLETE "TAP" {"ok":true,"count":0,"pass":0,"fail":0,"bailout":false,"todo":0,"skip":0,"plan":{"start":1,"end":0,"skipAll":true,"skipReason":"","comment":""},"failures":[]}
-TAP {PID} TAP: done processing [] false
+TAP {pid} TAP: END implicit=true
+TAP {pid} TAP: PROCESSING(TAP) 3
+TAP {pid} TAP: > STRING
+TAP {pid} TAP: LINE "TAP version 13\\n"
+TAP {pid} TAP: < already processing
+TAP {pid} TAP: > STRING
+TAP {pid} TAP: LINE "1..0\\n"
+TAP {pid} TAP: > METHOD
+TAP {pid} TAP: END implicit=true
+TAP {pid} TAP: < already processing
+TAP {pid} TAP: > EOF TAP
+TAP {pid} TAP: ONCOMPLETE "TAP" {"ok":true,"count":0,"pass":0,"fail":0,"bailout":false,"todo":0,"skip":0,"plan":{"start":1,"end":0,"skipAll":true,"skipReason":"","comment":""},"failures":[]}
+TAP {pid} TAP: done processing [] false
 
 `
 
@@ -400,8 +397,10 @@ TAP version 13
 ok 1 - fine
 not ok 2 - timeout!
   ---
-  signal: SIGTERM
   expired: TAP
+  handles:
+    - type: Timer
+  signal: SIGTERM
   stack: |
     {STACK}
   test: TAP
@@ -426,10 +425,10 @@ TAP version 13
 ok 1 - fine
 not ok 2 - timeout!
   ---
-  signal: SIGTERM
+  expired: TAP
   handles:
     - type: Timer
-  expired: TAP
+  signal: SIGTERM
   stack: |
     {STACK}
   test: TAP
@@ -454,10 +453,10 @@ TAP version 13
 ok 1 - fine
 not ok 2 - timeout!
   ---
-  signal: SIGTERM
-  requests:
-    {REQUESTS}
   expired: TAP
+  requests:
+    - type: FSReqWrap
+  signal: SIGTERM
   stack: |
     {STACK}
   test: TAP
diff --git a/tap-snapshots/test-test.js-TAP.test.js b/tap-snapshots/test-test.js-TAP.test.js
index a283c8f..2fbeadd 100644
--- a/tap-snapshots/test-test.js-TAP.test.js
+++ b/tap-snapshots/test-test.js-TAP.test.js
@@ -123,7 +123,6 @@ not ok 1 - i will do this later # TODO
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, 'i will do this later', { todo: true })
   ...
@@ -134,7 +133,6 @@ not ok 2 - expect falsey value # TODO later
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, { todo: 'later' })
   ...
@@ -157,7 +155,6 @@ not ok 1 - i will do this later # TODO
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, 'i will do this later', { todo: true })
   ...
@@ -168,7 +165,6 @@ not ok 2 - expect falsey value # TODO later
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, { todo: 'later' })
   ...
@@ -191,7 +187,6 @@ not ok 1 - i will do this later # TODO
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, 'i will do this later', { todo: true })
   ...
@@ -202,7 +197,6 @@ not ok 2 - expect falsey value # TODO later
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, { todo: 'later' })
   ...
@@ -225,7 +219,6 @@ not ok 1 - i will do this later # TODO
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, 'i will do this later', { todo: true })
   ...
@@ -236,7 +229,6 @@ not ok 2 - expect falsey value # TODO later
     line: #
     column: #
     file: test/test.js
-    function: todo
   source: |
     tt.notOk(true, { todo: 'later' })
   ...
@@ -340,7 +332,6 @@ not ok 2 - (unnamed test) # TODO
     line: #
     column: #
     file: test/test.js
-    function: no plan fail
   source: |
     tt.fail({ todo: true })
   ...
@@ -351,11 +342,10 @@ not ok 3 - this is fine
     line: #
     column: #
     file: test/test.js
-    function: no plan fail
-  stack: |
-    {STACK}
   source: |
     tt.fail('this is fine')
+  stack: |
+    {STACK}
   ...
 
 1..3
@@ -373,7 +363,6 @@ not ok 2 - (unnamed test) # TODO
     line: #
     column: #
     file: test/test.js
-    function: no plan fail
   source: |
     tt.fail({ todo: true })
   ...
@@ -384,11 +373,10 @@ not ok 3 - this is fine
     line: #
     column: #
     file: test/test.js
-    function: no plan fail
-  stack: |
-    {STACK}
   source: |
     tt.fail('this is fine')
+  stack: |
+    {STACK}
   ...
 
 1..3
@@ -413,7 +401,6 @@ not ok 2 - (unnamed test) # TODO
     line: #
     column: #
     file: test/test.js
-    function: no plan fail
   source: |
     tt.fail({ todo: true })
   ...
@@ -424,11 +411,10 @@ not ok 3 - this is fine
     line: #
     column: #
     file: test/test.js
-    function: no plan fail
-  stack: |
-    {STACK}
   source: |
     tt.fail('this is fine')
+  stack: |
+    {STACK}
   ...
 
 1..3
@@ -478,12 +464,10 @@ TAP version 13
         line: #
         column: #
         file: test/test.js
-        type: Test
-        function: tt.test.tt
-      stack: |
-        {STACK}
       source: |
         tt.fail('this is not ok')
+      stack: |
+        {STACK}
       ...
     
     1..1
@@ -504,12 +488,10 @@ TAP version 13
         line: #
         column: #
         file: test/test.js
-        type: Test
-        function: tt.test.tt
-      stack: |
-        {STACK}
       source: |
         tt.fail('this is not ok')
+      stack: |
+        {STACK}
       ...
     
     1..1
@@ -530,12 +512,10 @@ TAP version 13
         line: #
         column: #
         file: test/test.js
-        type: Test
-        function: tt.test.tt
-      stack: |
-        {STACK}
       source: |
         tt.fail('this is not ok')
+      stack: |
+        {STACK}
       ...
     
     Bail out! # this is not ok
@@ -988,11 +968,10 @@ not ok 1 - ok
     line: #
     column: #
     file: test/test.js
-    function: Object.gentle thrower
-  stack: |
-    {STACK}
   source: |
     'gentle thrower': tt => tt.threw(new Error('ok')),
+  stack: |
+    {STACK}
   ...
 
 1..1
@@ -1008,11 +987,10 @@ not ok 1 - ok
     line: #
     column: #
     file: test/test.js
-    function: Object.gentle thrower
-  stack: |
-    {STACK}
   source: |
     'gentle thrower': tt => tt.threw(new Error('ok')),
+  stack: |
+    {STACK}
   ...
 
 1..1
@@ -1028,11 +1006,10 @@ not ok 1 - ok
     line: #
     column: #
     file: test/test.js
-    function: Object.gentle thrower
-  stack: |
-    {STACK}
   source: |
     'gentle thrower': tt => tt.threw(new Error('ok')),
+  stack: |
+    {STACK}
   ...
 
 Bail out! # ok
@@ -1043,16 +1020,15 @@ exports[`test/test.js TAP short output checks gentle thrower runOnly > gentle th
 TAP version 13
 not ok 1 - ok
   ---
-  runOnly: true
   at:
     line: #
     column: #
     file: test/test.js
-    function: Object.gentle thrower
-  stack: |
-    {STACK}
+  runOnly: true
   source: |
     'gentle thrower': tt => tt.threw(new Error('ok')),
+  stack: |
+    {STACK}
   ...
 
 1..1
@@ -1065,16 +1041,15 @@ TAP version 13
 # Subtest: child test
     not ok 1 - ok
       ---
-      stack: |
-        {STACK}
       at:
         line: #
         column: #
         file: test/test.js
-        function: Test.tt.test.tt
-      test: child test
       source: |
         tt.threw(new Error('ok'))).then(tt.end),
+      stack: |
+        {STACK}
+      test: child test
       ...
     
     1..1
@@ -1091,16 +1066,15 @@ TAP version 13
 # Subtest: child test
     not ok 1 - ok
       ---
-      stack: |
-        {STACK}
       at:
         line: #
         column: #
         file: test/test.js
-        function: Test.tt.test.tt
-      test: child test
       source: |
         tt.threw(new Error('ok'))).then(tt.end),
+      stack: |
+        {STACK}
+      test: child test
       ...
     
     1..1
@@ -1117,16 +1091,15 @@ TAP version 13
 # Subtest: child test
     not ok 1 - ok
       ---
-      stack: |
-        {STACK}
       at:
         line: #
         column: #
         file: test/test.js
-        function: Test.tt.test.tt
-      test: child test
       source: |
         tt.threw(new Error('ok'))).then(tt.end),
+      stack: |
+        {STACK}
+      test: child test
       ...
     
     Bail out! # ok
@@ -1151,15 +1124,14 @@ ok 1 # {time}
 
 not ok 2 - beep
   ---
-  stack: |
-    {STACK}
   at:
     line: #
     column: #
     file: test/test.js
-    function: Test.<anonymous>
   source: |
     throw new Error('beep')
+  stack: |
+    {STACK}
   ...
 
 1..2
@@ -1177,15 +1149,14 @@ ok 1 # {time}
 
 not ok 2 - beep
   ---
-  stack: |
-    {STACK}
   at:
     line: #
     column: #
     file: test/test.js
-    function: Test.<anonymous>
   source: |
     throw new Error('beep')
+  stack: |
+    {STACK}
   ...
 
 1..2
@@ -1203,15 +1174,14 @@ ok 1 # {time}
 
 not ok 2 - beep
   ---
-  stack: |
-    {STACK}
   at:
     line: #
     column: #
     file: test/test.js
-    function: Test.<anonymous>
   source: |
     throw new Error('beep')
+  stack: |
+    {STACK}
   ...
 
 Bail out! # beep
@@ -1231,66 +1201,62 @@ TAP version 13
 ok 1 - this is not an error
 not ok 2 - this error is poop
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     name: Error
     stack: |
       {STACK}
     message: 'fail: poop'
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: error
-  stack: |
-    {STACK}
   source: |
     tt.error(new Error('fail: poop'), 'this error is poop')
+  stack: |
+    {STACK}
   ...
 
 not ok 3 - fail: poop
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     name: Error
     stack: |
       {STACK}
     message: 'fail: poop'
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: error
-  stack: |
-    {STACK}
   source: |
     tt.error(new Error('fail: poop'))
+  stack: |
+    {STACK}
   ...
 
 not ok 4 - this error is "poop"
   ---
-  found: 'fail: poop'
   at:
     line: #
     column: #
     file: test/test.js
-    function: error
-  stack: |
-    {STACK}
+  found: 'fail: poop'
   source: |
     tt.error('fail: poop', 'this error is "poop"')
+  stack: |
+    {STACK}
   ...
 
 not ok 5 - non-Error error encountered
   ---
-  found: 'fail: poop'
   at:
     line: #
     column: #
     file: test/test.js
-    function: error
-  stack: |
-    {STACK}
+  found: 'fail: poop'
   source: |
     tt.error('fail: poop')
+  stack: |
+    {STACK}
   ...
 
 ok 6 - should not error # TODO
@@ -1305,39 +1271,37 @@ exports[`test/test.js TAP assertions and weird stuff equal > equal 1`] = `
 TAP version 13
 not ok 1 - should be equal
   ---
-  found: 1
-  wanted: 2
-  compare: ===
   at:
     line: #
     column: #
     file: test/test.js
-    function: equal
-  stack: |
-    {STACK}
+  compare: ===
+  found: 1
   source: |
     tt.equal(1, 2)
+  stack: |
+    {STACK}
+  wanted: 2
   ...
 
 not ok 2 - should be equal # SKIP
 ok 3 - one is one
 not ok 4 - should be equal
   ---
-  found:
-    foo: 1
-  wanted:
-    foo: 1
-  compare: ===
-  note: Objects never === one another
   at:
     line: #
     column: #
     file: test/test.js
-    function: equal
-  stack: |
-    {STACK}
+  compare: ===
+  found:
+    foo: 1
+  note: Objects never === one another
   source: |
     tt.equal({foo: 1}, {foo: 1})
+  stack: |
+    {STACK}
+  wanted:
+    foo: 1
   ...
 
 1..4
@@ -1352,18 +1316,17 @@ ok 1 - should not be equal
 ok 2 - should not be equal # SKIP
 not ok 3 - one is not one
   ---
-  found: 1
-  doNotWant: 1
-  compare: '!=='
   at:
     line: #
     column: #
     file: test/test.js
-    function: not
-  stack: |
-    {STACK}
+  compare: '!=='
+  doNotWant: 1
+  found: 1
   source: |
     tt.not(1, 1, 'one is not one')
+  stack: |
+    {STACK}
   ...
 
 ok 4 - should not be equal
@@ -1383,43 +1346,41 @@ ok 5 - this one passes
 ok 6 - should not be equivalent # SKIP
 not ok 7 - this one fails
   ---
-  found:
-    foo:
-      bar: 2
-  doNotWant:
-    foo:
-      bar: '2'
   at:
     line: #
     column: #
     file: test/test.js
-    function: same
-  stack: |
-    {STACK}
+  doNotWant:
+    foo:
+      bar: '2'
+  found:
+    foo:
+      bar: 2
   source: |
     tt.notSame({ foo: { bar: 2 } }, { foo: { bar: '2' } },
+  stack: |
+    {STACK}
   ...
 
 not ok 8 - should be equivalent strictly # SKIP
 not ok 9 - should be equivalent strictly
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     - 1
     - 2
     - 3
+  source: |
+    tt.strictSame([1, 2, 3], ['1', '2', '3'])
+  stack: |
+    {STACK}
   wanted:
     - '1'
     - '2'
     - '3'
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: same
-  stack: |
-    {STACK}
-  source: |
-    tt.strictSame([1, 2, 3], ['1', '2', '3'])
   ...
 
 ok 10 - should be equivalent strictly
@@ -1429,21 +1390,20 @@ ok 13 - this one passes
 ok 14 - this one passes
 not ok 15 - this one fails
   ---
-  found:
-    foo:
-      bar: 2
-  doNotWant:
-    foo:
-      bar: 2
   at:
     line: #
     column: #
     file: test/test.js
-    function: same
-  stack: |
-    {STACK}
+  doNotWant:
+    foo:
+      bar: 2
+  found:
+    foo:
+      bar: 2
   source: |
     tt.notStrictSame({ foo: { bar: 2 } }, { foo: { bar: 2 } },
+  stack: |
+    {STACK}
   ...
 
 1..15
@@ -1457,78 +1417,74 @@ TAP version 13
 ok 1 - should match pattern provided
 not ok 2 - should match pattern provided
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     a: b
     c: /asdf/
   pattern:
     a: asdf
     c: 1
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: match
-  stack: |
-    {STACK}
   source: |
     tt.match({ a: 'b', c: /asdf/ }, { a: 'asdf', c: 1 })
+  stack: |
+    {STACK}
   ...
 
 ok 3 - a message
 not ok 4 - should match pattern provided # TODO
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     a: b
     c: /asdf/
   pattern:
     a: asdf
     c: 1
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: match
   source: |
     tt.match({ a: 'b', c: /asdf/ }, { a: 'asdf', c: 1 },
   ...
 
 not ok 5 - should not match pattern provided
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     a: b
     c: /asdf/
   pattern:
     a: 'function String() { [native code] }'
     c: 'function RegExp() { [native code] }'
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: match
-  stack: |
-    {STACK}
   source: |
     tt.notMatch({ a: 'b', c: /asdf/ }, { a: String, c: RegExp })
+  stack: |
+    {STACK}
   ...
 
 ok 6 - should not match pattern provided
 not ok 7 - a message
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     a: b
     c: /asdf/
   pattern:
     a: 'function String() { [native code] }'
     c: 'function RegExp() { [native code] }'
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    function: match
-  stack: |
-    {STACK}
   source: |
     tt.notMatch({ a: 'b', c: /asdf/ }, { a: String, c: RegExp },
+  stack: |
+    {STACK}
   ...
 
 ok 8 - should not match pattern provided # TODO
@@ -1542,18 +1498,17 @@ exports[`test/test.js TAP assertions and weird stuff type > type 1`] = `
 TAP version 13
 not ok 1 - this fails
   ---
-  found: 'null'
-  wanted: object
-  compare: ===
   at:
     line: #
     column: #
     file: test/test.js
-    function: type
-  stack: |
-    {STACK}
+  compare: ===
+  found: 'null'
   source: |
     tt.type(null, 'object', 'this fails')
+  stack: |
+    {STACK}
+  wanted: object
   ...
 
 ok 2 - type is object
@@ -1561,17 +1516,16 @@ ok 3 - type is number
 ok 4 - type is Test
 not ok 5 - fails, anonymously
   ---
-  found: Object
-  wanted: (anonymous constructor)
   at:
     line: #
     column: #
     file: test/test.js
-    function: type
-  stack: |
-    {STACK}
+  found: Object
   source: |
     tt.type({}, function () {}, 'fails, anonymously')
+  stack: |
+    {STACK}
+  wanted: (anonymous constructor)
   ...
 
 ok 6 - a thing is a thing
@@ -1579,18 +1533,17 @@ ok 7 - arrows are functions
 ok 8 - arrows are functions
 not ok 9 - fail: arrows are not objects
   ---
-  found: function
-  wanted: Object
-  compare: ===
   at:
     line: #
     column: #
     file: test/test.js
-    function: type
-  stack: |
-    {STACK}
+  compare: ===
+  found: function
   source: |
     tt.type(() => {}, Object, 'fail: arrows are not objects')
+  stack: |
+    {STACK}
+  wanted: Object
   ...
 
 ok 10 - type is object
@@ -1618,11 +1571,10 @@ not ok 10 - fail: does not throw actually
     line: #
     column: #
     file: test/test.js
-    function: throws
-  stack: |
-    {STACK}
   source: |
     tt.throws(() => 'doesnt tho', 'fail: does not throw actually')
+  stack: |
+    {STACK}
   ...
 
 ok 11 - expected to throw # SKIP
@@ -1648,12 +1600,11 @@ not ok 5 - fail
     line: #
     column: #
     file: test/test.js
-    function: tt.doesNotThrow
-  stack: |
-    {STACK}
   message: ouch
   source: |
     throw new Error('ouch')
+  stack: |
+    {STACK}
   ...
 
 1..5
@@ -1762,7 +1713,6 @@ not ok 19 - fail: passing promise # {time} {
         line: #
         column: #
         file: test/test.js
-        function: rejects
       found: 420
       source: |
         tt.rejects(new Promise(r => r(420)), 'fail: passing promise')
@@ -1889,8 +1839,6 @@ not ok 1 - expect fail
     line: #
     column: #
     file: test/test.js
-    type: global
-    function: baz
   source: |
     const baz = () => { tt.assertAt = stack.at(); bar() }
   ...
@@ -1904,15 +1852,14 @@ TAP version 13
 1..1
 not ok 1 - expect fail
   ---
-  stack: |
-    {STACK}
   at:
     line: #
     column: #
     file: test/test.js
-    function: baz
   source: |
     const baz = () => { tt.assertStack = stack.captureString(80); bar() }
+  stack: |
+    {STACK}
   ...
 
 # failed 1 test
@@ -1973,16 +1920,15 @@ ok 1 - child # {time}
 
 not ok 2 - catch it in the parent
   ---
-  stack: |
-    {STACK}
   at:
     line: #
     column: #
     file: test/test.js
-    function: Test.tt.test.tt
-  test: child
   source: |
     tt.threw(new Error('catch it in the parent'))
+  stack: |
+    {STACK}
+  test: child
   ...
 
 1..2
@@ -1995,16 +1941,15 @@ TAP version 13
 # Subtest: child
     not ok 1 - poop
       ---
-      stack: |
-        {STACK}
       at:
         line: #
         column: #
         file: test/test.js
-        function: Promise
-      test: child
       source: |
         tt.test('child', () => new Promise((_, r) => r(new Error('poop'))))
+      stack: |
+        {STACK}
+      test: child
       ...
     
     1..1
@@ -2024,16 +1969,15 @@ ok 1 - child # {time}
 
 not ok 2 - fail
   ---
-  stack: |
-    {STACK}
   at:
     line: #
     column: #
     file: test/test.js
-    function: Test.tt.teardown
-  test: child
   source: |
     tt.teardown(() => { throw new Error('fail') })
+  stack: |
+    {STACK}
+  test: child
   ...
 
 1..2
@@ -2166,9 +2110,9 @@ ok 5 - autoend async limit # {time}
 
 not ok 6 - cannot create subtest after parent test end # {time}
   ---
+  autoend: true
   stack: |
     {STACK}
-  autoend: true
   test: autoend async limit
   ...
 
@@ -2185,16 +2129,15 @@ TAP version 13
         # Subtest: misbehaving child
             not ok 1 - test unfinished
               ---
-              stack: |
-                {STACK}
-              test: misbehaving child
               at:
                 line: #
                 column: #
                 file: test/test.js
-                function: Test.tt.test.tt
               source: |
                 tt.test('misbehaving child', () => new Promise(()=>{}))
+              stack: |
+                {STACK}
+              test: misbehaving child
               ...
             
             1..1
@@ -2240,12 +2183,10 @@ TAP version 13
         line: #
         column: #
         file: test/test.js
-        type: Test
-        function: tt.test.tt
-      stack: |
-        {STACK}
       source: |
         tt.fail('not fine')
+      stack: |
+        {STACK}
       ...
     
     Bail out! # not fine
@@ -2316,31 +2257,31 @@ TAP version 13
     not ok 1 - timeout!
       ---
       expired: get lost buf=false
-      timeout: 1
       stack: |
         {STACK}
       test: get lost buf=false
+      timeout: 50
       ...
     
     1..1
     # failed 1 test
 not ok 1 - get lost buf=false # {time}
   ---
-  timeout: 1
+  timeout: 50
   ...
 
 not ok 2 - get lost buf=true # {time}
   ---
-  timeout: 1
+  timeout: 50
   ...
 {
     not ok 1 - timeout!
       ---
       expired: get lost buf=true
-      timeout: 1
       stack: |
         {STACK}
       test: get lost buf=true
+      timeout: 50
       ...
     
     1..1
@@ -2372,12 +2313,12 @@ TAP version 13
     # failed 1 test
 not ok 1 - get lost buf=false # {time}
   ---
-  timeout: 1
+  timeout: 50
   ...
 
 not ok 2 - get lost buf=true # {time}
   ---
-  timeout: 1
+  timeout: 50
   ...
 {
     # Subtest: carry on
@@ -2412,10 +2353,10 @@ ok 1 - work it harder buf=false # {time}
 not ok 2 - timeout! # {time}
   ---
   expired: work it harder buf=false
-  timeout: 1
   stack: |
     {STACK}
   test: work it harder buf=false
+  timeout: 1
   ...
 
 ok 3 - work it harder buf=true # {time} {
@@ -2426,10 +2367,10 @@ ok 3 - work it harder buf=true # {time} {
 not ok 4 - timeout!
   ---
   expired: work it harder buf=true
-  timeout: 1
   stack: |
     {STACK}
   test: work it harder buf=true
+  timeout: 1
   ...
 
 1..4
@@ -2441,6 +2382,10 @@ exports[`test/test.js TAP addAssert > using the custom isUrl assertion 1`] = `
 TAP version 13
 not ok 1 - expect a valid http/https url
   ---
+  at:
+    line: #
+    column: #
+    file: test/test.js
   found:
     protocol: null
     slashes: null
@@ -2459,16 +2404,10 @@ not ok 1 - expect a valid http/https url
     slashes: true
     host: 'function String() { [native code] }'
     path: /^\\/.*$/
-  at:
-    line: #
-    column: #
-    file: test/test.js
-    type: Test
-    function: t.test.t
-  stack: |
-    {STACK}
   source: |
     tt.isUrl('hello is not a url')
+  stack: |
+    {STACK}
   ...
 
 ok 2 - x is a url!
diff --git a/test/clean-stacks.js b/test/clean-stacks.js
new file mode 100644
index 0000000..e09eb59
--- /dev/null
+++ b/test/clean-stacks.js
@@ -0,0 +1,53 @@
+'use strict'
+
+// Just a utility to clean up the snapshots for output tests
+
+const yaml = require('js-yaml')
+module.exports = out => out
+  // sort keys in yaml blocks
+  .replace(/\n(   *)---\n((\1.*\n)*)\1\.\.\.\n/g, ($0, $1, $2) => {
+    let o
+    try {
+      o = yaml.safeLoad($2)
+    } catch (er) {
+      return $0
+    }
+    const out = Object.keys(o).sort().reduce((s, k) => {
+      if (k === 'requests' || k === 'handles')
+        o[k] = o[k].map(r => ({ type: r.type }))
+      s[k] = o[k]
+      return s
+    }, {})
+    return '\n' + $1 + '---\n' + $1 +
+      yaml.safeDump(out).trim().split('\n').join('\n' + $1)
+      + '\n' + $1 + '...\n'
+  })
+
+  // remove time details
+  .replace(/ # time=[0-9\.]+m?s( \{.*)?\n/g, ' # {time}$1\n')
+  .replace(/\n# time=.*/g, '\n# {time}')
+
+  // debug output
+  .replace(/(\n|^)TAP ([0-9]+) /g, '$1TAP {pid} ')
+
+  // stacks are always changing
+  .replace(/\n(( {2})+)stack: \|-?\n((\1  .*).*\n)+/gm,
+    '\n$1stack: |\n$1  {STACK}\n')
+  .replace(/\n(( {2})+)stack: \>-?\n((\1  .*).*\n(\1\n)?)+/gm,
+    '\n$1stack: |\n$1  {STACK}\n')
+  .replace(/(?:\n|^)([a-zA-Z]*Error): (.*)\n((    at .*\n)*)+/gm,
+    '\n$1: $2\n    {STACK}\n')
+  .replace(/:[0-9]+:[0-9]+(\)?\n)/g, '#:#$1')
+  .replace(/(line|column): [0-9]+/g, '$1: #')
+
+  // type and function change often between node/v8 versions
+  .replace(/\n( +)function: .*(\n\1  .*)*\n/g, '\n')
+  .replace(/\n( +)method: .*(\n\1  .*)*\n/g, '\n')
+  .replace(/\n( +)type: .*\n/g, '\n')
+
+  // fix references to cwd
+  .split(process.cwd()).join('{CWD}')
+
+// nothing to see here
+if (module === require.main)
+  console.log('TAP version 13\n1..1\nok - 1\n')
diff --git a/test/run.js b/test/run.js
index 58bc67f..7c70885 100644
--- a/test/run.js
+++ b/test/run.js
@@ -12,22 +12,7 @@ const t = require('../')
 const dir = path.join(__dirname, 'cli-tests')
 mkdirp.sync(dir)
 
-const clean = out => out
-  .replace(/(^|\n)TAP [0-9]+ /g, '$1TAP {PID} ')
-  .replace(
-    /\n((?:  )+)requests:\n(\1  - type:(.*)\n\1 {4}context:\n(\1 {6}.*\n)+)+/g,
-    '\n$1requests:\n$1  {REQUESTS}\n')
-  .replace(/\bfd: [0-9]+/g, 'fd: {FD}')
-  .replace(/# time=[0-9\.]+m?s( \{.*)?\n/g, '# {time}$1\n')
-  .replace(/\n(( {2})+)stack: \|-?\n((\1  .*).*\n)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/\n(( {2})+)stack: \>-?\n((\1  .*).*\n(\1\n)?)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/(?:\n|^)([a-zA-Z]*Error): (.*)\n((    at .*\n)*)+/gm,
-    '\n$1: $2\n    {STACK}\n')
-  .replace(/:[0-9]+:[0-9]+(\)?\n)/g, '#:#$1')
-  .replace(/(line|column): [0-9]+/g, '$1: #')
-  .split(process.cwd()).join('{CWD}')
+const clean = require('./clean-stacks.js')
 
 const run = (args, options, cb) => {
   if (options && options.env)
@@ -267,18 +252,19 @@ t.test('stdin', t => {
   })
 
   t.test('with file', t => {
-    const foo = tmpfile(t, 'foo.js', `
+    const foo = tmpfile(t, 'foo.test.js', `
       'use strict'
       require(${tap}).test('child', t => {
         t.pass('this is fine')
         t.end()
       })
     `)
-    const args = ['-', 'foo.js', '-CRclassic', '-ofoo.txt']
+    const args = ['-', foo, '-CRclassic', '-ofoo.txt']
     const c = run(args, { env: { TAP: 0, TAP_BUFFER: 1 }}, (er, o, e) => {
       t.equal(er, null)
       t.matchSnapshot(clean(fs.readFileSync('foo.txt', 'utf8')))
-      t.match(o, /foo.js \.+ 1\/1.*\n\/dev\/stdin \.+ 1\/1\n/)
+      t.match(o, /foo.test.js \.+ 1\/1.*\n\/dev\/stdin \.+ 1\/1\n/)
+      fs.unlinkSync('foo.txt')
       t.end()
     })
     c.stdin.end(tapcode)
diff --git a/test/spawn.js b/test/spawn.js
index 1f497fc..a2c033b 100644
--- a/test/spawn.js
+++ b/test/spawn.js
@@ -8,17 +8,7 @@ const file = __filename
 process.env.TAP_BAIL = ''
 process.env.TAP_BUFFER = ''
 
-const clean = out => out
-  .replace(/ # time=[0-9\.]+m?s( \{.*)?\n/g, ' # {time}$1\n')
-  .replace(/\n(( {2})+)stack: \|-?\n((\1  .*).*\n)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/\n(( {2})+)stack: \>-?\n((\1  .*).*\n(\1\n)?)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/\n([a-zA-Z]*Error): (.*)\n((    at .*\n)*)+/gm,
-    '\n$1: $2\n    {STACK}\n')
-  .replace(/:[0-9]+:[0-9]+(\)?\n)/g, '#:#$1')
-  .replace(/(line|column): [0-9]+/g, '$1: #')
-  .split(process.cwd()).join('{CWD}')
+const clean = require('./clean-stacks.js')
 
 const main = () => {
   t.test('basic child process', t =>
diff --git a/test/tap.js b/test/tap.js
index 39e53dd..09ba2cd 100644
--- a/test/tap.js
+++ b/test/tap.js
@@ -1,22 +1,7 @@
 'use strict'
 const node = process.execPath
 
-const clean = out => out
-  .replace(/(^|\n)TAP [0-9]+ /g, '$1TAP {PID} ')
-  .replace(
-    /\n((?:  )+)requests:\n(\1  - type:(.*)\n\1 {4}context:\n(\1 {6}.*\n)+)+/g,
-    '\n$1requests:\n$1  {REQUESTS}\n')
-  .replace(/\bfd: [0-9]+/g, 'fd: {FD}')
-  .replace(/# time=[0-9\.]+m?s( \{.*)?\n/g, '# {time}$1\n')
-  .replace(/\n(( {2})+)stack: \|-?\n((\1  .*).*\n)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/\n(( {2})+)stack: \>-?\n((\1  .*).*\n(\1\n)?)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/(?:\n|^)([a-zA-Z]*Error): (.*)\n((    at .*\n)*)+/gm,
-    '\n$1: $2\n    {STACK}\n')
-  .replace(/:[0-9]+:[0-9]+(\)?\n)/g, '#:#$1')
-  .replace(/(line|column): [0-9]+/g, '$1: #')
-  .split(process.cwd()).join('{CWD}')
+const clean = require('./clean-stacks.js')
 
 const cases = {
   ok: t => t.pass('fine'),
@@ -100,6 +85,7 @@ const cases = {
   'timeout sigterm': t => {
     t.pass('fine')
     process.kill(process.pid, 'SIGTERM')
+    setTimeout(() => {}, 1000)
   },
   'timeout sigterm with handle': t => {
     setTimeout(() => {}, 10000)
@@ -123,9 +109,13 @@ const main = t => {
   const spawn = require('child_process').spawn
   const keys = Object.keys(cases)
   t.plan(keys.length)
+  const env = Object.keys(process.env).reduce((env, k) => {
+    env[k] = env[k] || process.env[k]
+    return env
+  }, { TAP_BAIL: '0', TAP_BUFFER: '0' })
   keys.forEach(k => t.test(k, t => {
     t.plan(3)
-    const c = spawn(node, [__filename, k])
+    const c = spawn(node, [__filename, k], { env: env })
     let out = ''
     c.stdout.on('data', c => out += c)
     let err = ''
diff --git a/test/test.js b/test/test.js
index f06851a..1be4f1f 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,3 +1,4 @@
+'use strict'
 const t = require('../')
 const fs = require('fs')
 const path = require('path')
@@ -11,18 +12,7 @@ const MiniPass = require('minipass')
 process.env.TAP_DIAG = ''
 process.env.TAP_BAIL = ''
 
-const clean = out => out
-  .replace(/ # time=[0-9\.]+m?s( \{.*)?\n/g, ' # {time}$1\n')
-  .replace(/\n(( {2})+)stack: \|-?\n((\1  .*).*\n)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/\n(( {2})+)stack: \>-?\n((\1  .*).*\n(\1\n)?)+/gm,
-    '\n$1stack: |\n$1  {STACK}\n')
-  .replace(/\n([a-zA-Z]*Error): (.*)\n((    at .*\n)*)+/gm,
-    '\n$1: $2\n    {STACK}\n')
-  .replace(/:[0-9]+:[0-9]+(\)?\n)/g, '#:#$1')
-  .replace(/(line|column): [0-9]+/g, '$1: #')
-  .split(process.cwd()).join('{CWD}')
-
+const clean = require('./clean-stacks.js')
 
 t.test('short output checks', t => {
   const env = process.env.TAP_BUFFER
@@ -730,7 +720,7 @@ t.test('assertions and weird stuff', t => {
     'timeout expiration': t => {
       const buf = [ false, true ]
       buf.forEach(buf => {
-        t.test('get lost buf=' + buf, { buffered: buf, timeout: 1 }, t => {
+        t.test('get lost buf=' + buf, { buffered: buf, timeout: 50 }, t => {
           const timer = setTimeout(() => {}, 10000)
           t.on('timeout', () => clearTimeout(timer))
         })
@@ -741,7 +731,7 @@ t.test('assertions and weird stuff', t => {
     'timeout with subs': t => {
       const buf = [ false, true ]
       buf.forEach(buf => {
-        t.test('get lost buf=' + buf, { buffered: buf, timeout: 1 }, t => {
+        t.test('get lost buf=' + buf, { buffered: buf, timeout: 50 }, t => {
           const timer = setTimeout(() => {}, 10000)
           t.test('carry on', t => t.on('timeout', () => clearTimeout(timer)))
         })

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap.git



More information about the Pkg-javascript-commits mailing list