[Pkg-javascript-commits] [node-tap] 01/04: Imported Upstream version 0.7.1

Ximin Luo infinity0 at debian.org
Mon Aug 31 02:38:50 UTC 2015


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

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

commit 4d553523372d43932906ae3064b784d48400a8d5
Author: Ximin Luo <infinity0 at debian.org>
Date:   Mon Aug 31 04:24:33 2015 +0200

    Imported Upstream version 0.7.1
---
 README.md                               |  2 +-
 bin/tap.js                              |  7 +++-
 lib/tap-assert.js                       | 23 ++++++++++-
 lib/tap-global-harness.js               | 12 ++++++
 lib/tap-harness.js                      | 10 +++--
 lib/tap-producer.js                     |  4 +-
 lib/tap-results.js                      | 39 ++++++++++---------
 lib/tap-runner.js                       |  9 +++--
 package.json                            | 14 +++----
 test/debug-test.js                      |  5 ++-
 test/{deep.js => deep-strict.js}        | 18 ++++-----
 test/deep.js                            | 24 ++++++------
 test/exit-code.js                       | 69 +++++++++++++++++++++++++++++++++
 test/expose-gc-test.js                  | 23 +++++++----
 test/fixtures/fail-correct-exit.js      |  4 ++
 test/fixtures/fail-exit.js              |  4 ++
 test/fixtures/fail-zero-exit.js         |  4 ++
 test/fixtures/success.js                |  3 ++
 test/fixtures/todo-skip-descriptions.js |  4 ++
 test/fixtures/trivial-success.js        |  1 +
 test/nested-async.js                    | 36 +++++++++++++++++
 test/nested-test.js                     |  3 +-
 test/not-executed.sh                    |  1 +
 test/result-trap.js                     | 13 ++-----
 test/segv.js                            |  3 +-
 test/test-assert-todo-skip.js           | 13 +++++++
 test/test-directives.js                 | 48 +++++++++++++++++++++++
 test/test-skip.js                       |  5 +++
 test/valid-command.js                   |  2 +-
 29 files changed, 319 insertions(+), 84 deletions(-)

diff --git a/README.md b/README.md
index d6a0440..bed3955 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ For extra special bonus points, you can do something like this:
     test("make sure the thingie is a thing", function (t) {
       t.equal(thingie, "thing", "thingie should be thing")
       t.deepEqual(array, ["foo", "bar"], "array has foo and bar elements")
-      t.deepEqual(object, {foo: 42}, "object has foo property")
+      t.strictDeepEqual(object, {foo: 42, bar: "thingie"}, "object has foo (Number) and bar (String) property")
       t.type(thingie, "string", "type of thingie is string")
       t.ok(true, "this is always true")
       t.notOk(false, "this is never true")
diff --git a/bin/tap.js b/bin/tap.js
index 0a9bbeb..c666040 100755
--- a/bin/tap.js
+++ b/bin/tap.js
@@ -114,7 +114,10 @@ if (options.tap || options.diag) {
     console.log("%s %s %s", s, dots, n)
     if (details.ok) {
       if (details.skip) {
-        console.log("  skipped: %s", details.skipTotal)
+        console.log("  skipped: %s", details.skip)
+      }
+      if (details.todo) {
+        console.log("  todo: %s", details.todo)
       }
     } else {
       // console.error(details)
@@ -140,5 +143,5 @@ if (options.tap || options.diag) {
 
 
 r.on("end", function () {
-  process.exit(r.results.tests - r.results.pass)
+  process.exit(r.results.ok ? 0 : 1)
 })
diff --git a/lib/tap-assert.js b/lib/tap-assert.js
index 60203a0..9838961 100644
--- a/lib/tap-assert.js
+++ b/lib/tap-assert.js
@@ -99,7 +99,8 @@ assert.fail = fail
 function skip (message, extra) {
   //console.error("assert.skip", message, extra)
   if (!extra) extra = {}
-  return { id: id ++, skip: true, name: message || "" }
+  return { id: id ++, skip: true, name: message || "",
+           explanation: extra.explanation || "" }
 }
 assert.skip = skip
 
@@ -191,6 +192,26 @@ syns.equivalent = ["isEquivalent"
                   ,"deepEqual"
                   ,"deepEquals"]
 
+function strictDeepEqual (a, b, message, extra) {
+  if (extra && extra.skip) return assert.skip(message, extra)
+  var extra = extra || {}
+  message = message || "should be strictly equal"
+  extra.found = a
+  extra.wanted = b
+
+  if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) {
+    return assert(bufferEqual(a, b), message, extra)
+  } else {
+    return assert(deepEqual(a, b, {strict: true}), message, extra)
+  }
+}
+assert.strictDeepEqual = strictDeepEqual
+syns.strictDeepEqual = ["isStrictEquivalent"
+                  ,"isStrictly"
+                  ,"exactSame"
+                  ,"strictDeepEqual"
+                  ,"strictDeepEquals"]
+
 
 function inequal (a, b, message, extra) {
   if (extra && extra.skip) return assert.skip(message, extra)
diff --git a/lib/tap-global-harness.js b/lib/tap-global-harness.js
index 2fb1933..3b04131 100644
--- a/lib/tap-global-harness.js
+++ b/lib/tap-global-harness.js
@@ -57,6 +57,18 @@ function GlobalHarness () {
       this.results.list.length = 0
       output.end()
       streamEnded = true
+
+      // If we had fails, then make sure that the exit code
+      // reflects that failure.
+      var exitCode
+      if (!this.results.ok)
+        exitCode = process.exitCode = 1
+      if (exitCode !== 0) {
+        process.on('exit', function (code) {
+          if (code === 0)
+            process.exit(exitCode)
+        })
+      }
     }
   })
 
diff --git a/lib/tap-harness.js b/lib/tap-harness.js
index f06f63c..1de0ca6 100644
--- a/lib/tap-harness.js
+++ b/lib/tap-harness.js
@@ -24,7 +24,7 @@ function Harness (Test) {
   this._Test = Test
   this._plan = null
   this._children = []
-  this._started = false
+  this._processing = false
 
   this._testCount = 0
   this._planSum = 0
@@ -40,7 +40,7 @@ function Harness (Test) {
 
   var p = this.process.bind(this)
   this.process = function () {
-    this._started = true
+    this._processing = true
     process.nextTick(p)
   }
 
@@ -87,13 +87,15 @@ Harness.prototype.process = function () {
     current.emit("ready")
     //console.error("emitted ready")
     //console.error("_plan", this._plan, this.constructor.name)
-  } else {
+  } else if (!this._plan || (this._plan && this._plan === this._testCount)) {
     //console.error("Harness process: no more left.  ending")
     if (this._endNice) {
       this._endNice()
     } else {
       this.end()
     }
+  } else {
+    this._processing = false;
   }
 }
 
@@ -214,7 +216,7 @@ Harness.prototype.bailout = function (message) {
 Harness.prototype.add = function (child) {
   //console.error("adding child")
   this._children.push(child)
-  if (!this._started) this.process()
+  if (!this._processing) this.process()
 }
 
 // the tearDown function is *always* guaranteed to happen.
diff --git a/lib/tap-producer.js b/lib/tap-producer.js
index 99dbb87..b70d0ce 100644
--- a/lib/tap-producer.js
+++ b/lib/tap-producer.js
@@ -111,8 +111,8 @@ function encodeResult (res, count, diag) {
   output += ( !res.ok ? "not " : "") + "ok " + count
             + ( !res.name ? ""
               : " " + res.name.replace(/[\r\n]/g, " ") )
-            + ( res.skip ? " # SKIP"
-              : res.todo ? " # TODO"
+            + ( res.skip ? " # SKIP " + ( res.explanation || "" )
+              : res.todo ? " # TODO " + ( res.explanation || "" )
               : "" )
             + "\n"
 
diff --git a/lib/tap-results.js b/lib/tap-results.js
index 6fe90e8..3243cd7 100644
--- a/lib/tap-results.js
+++ b/lib/tap-results.js
@@ -40,29 +40,30 @@ Results.prototype.addSet = function (r) {
 }
 
 Results.prototype.add = function (r, addToList) {
-  //console.error("add result", r)
-  var pf = r.ok ? "pass" : "fail"
-    , PF = r.ok ? "Pass" : "Fail"
+  if (typeof r === 'object') {
+    var pf = r.ok ? "pass" : "fail"
+      , PF = r.ok ? "Pass" : "Fail"
 
-  this.testsTotal ++
-  this[pf + "Total"] ++
+    this.testsTotal ++
+    this[pf + "Total"] ++
 
-  if (r.skip) {
-    this["skip" + PF] ++
-    this.skip ++
-  } else if (r.todo) {
-    this["todo" + PF] ++
-    this.todo ++
-  } else {
-    this.tests ++
-    this[pf] ++
-  }
+    if (r.skip) {
+      this["skip" + PF] ++
+      this.skip ++
+    } else if (r.todo) {
+      this["todo" + PF] ++
+      this.todo ++
+    } else {
+      this.tests ++
+      this[pf] ++
+    }
 
-  if (r.bailout || typeof r.bailout === "string") {
-    // console.error("Bailing out in result")
-    this.bailedOut = true
+    if (r.bailout || typeof r.bailout === "string") {
+      // console.error("Bailing out in result")
+      this.bailedOut = true
+    }
+    this.ok = !!(this.ok && (r.ok || r.skip || r.todo))
   }
-  this.ok = !!(this.ok && r.ok)
 
   if (addToList === false) return
   this.list = this.list || []
diff --git a/lib/tap-runner.js b/lib/tap-runner.js
index c60e8d1..d3689f0 100644
--- a/lib/tap-runner.js
+++ b/lib/tap-runner.js
@@ -49,7 +49,7 @@ function Runner (options, cb) {
       this.coverageOutDir = path.resolve(this.coverageOutDir)
       this.getFilesToCover(filesToCover)
       var self = this
-      return mkdirp(this.coverageOutDir, 0755, function (er) {
+      return mkdirp(this.coverageOutDir, '0755', function (er) {
         if (er) return self.emit("error", er)
         self.run(dir, cb)
       })
@@ -198,17 +198,18 @@ function runFiles(self, files, dir, cb) {
           args.push(fileName)
         } else {
           // Check if file is executable
-          if ((st.mode & 0100) && process.getuid) {
+          if ((st.mode & parseInt('0100', 8)) && process.getuid) {
             if (process.getuid() != st.uid) {
               return cb()
             }
-          } else if ((st.mode & 0010) && process.getgid) {
+          } else if ((st.mode & parseInt('0010', 8)) && process.getgid) {
             if (process.getgid() != st.gid) {
               return cb()
             }
-          } else if ((st.mode & 0001) == 0) {
+          } else if ((st.mode & parseInt('0001', 8)) == 0) {
             return cb()
           }
+          cmd = path.resolve(cmd)
         }
 
         if (st.isDirectory()) {
diff --git a/package.json b/package.json
index 4dcbdf3..1f99390 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "tap",
-  "version": "0.4.13",
+  "version": "0.7.1",
   "author": "Isaac Z. Schlueter <i at izs.me> (http://blog.izs.me)",
   "description": "A Test-Anything-Protocol library",
   "bin": "bin/tap.js",
@@ -10,12 +10,12 @@
   },
   "dependencies": {
     "buffer-equal": "~0.0.0",
-    "deep-equal": "~0.0.0",
+    "deep-equal": "^1.0.0",
     "difflet": "~0.2.0",
-    "glob": "~3.2.1",
+    "glob": "^4.3.5",
     "inherits": "*",
-    "mkdirp": "~0.3 || 0.4 || 0.5",
-    "nopt": "~2",
+    "mkdirp": "^0.5.0",
+    "nopt": "^3.0.1",
     "runforcover": "~0.0.2",
     "slide": "*",
     "yamlish": "*"
@@ -33,9 +33,9 @@
     "type": "MIT",
     "url": "https://github.com/isaacs/node-tap/raw/master/LICENSE"
   },
-  "repository": "git://github.com/isaacs/node-tap.git",
+  "repository": "https://github.com/isaacs/node-tap.git",
   "scripts": {
-    "test": "bin/tap.js test/*.js"
+    "test": "node --use_strict bin/tap.js test/*.*"
   },
   "devDependencies": {}
 }
diff --git a/test/debug-test.js b/test/debug-test.js
index a99ad40..d290315 100644
--- a/test/debug-test.js
+++ b/test/debug-test.js
@@ -9,8 +9,9 @@ tap.test("debug test", function (t) {
   console.error("t.plan="+t._plan)
 
   cp.exec("../bin/tap.js --debug meta-test.js", function (err, stdo, stde) {
-    console.error(util.inspect(stde)) 
-    t.notEqual(stde.indexOf("debugger listening on port"), -1, "Should output debugger message")
+    console.error(util.inspect(stde))
+    // node 0.10 print "debugger", 0.12 and iojs are printing "Debugger"
+    t.notEqual(stde.indexOf("ebugger listening on port"), -1, "Should output debugger message")
     t.end();
   })
 })
diff --git a/test/deep.js b/test/deep-strict.js
similarity index 56%
copy from test/deep.js
copy to test/deep-strict.js
index 52b6110..7dc9d5b 100644
--- a/test/deep.js
+++ b/test/deep-strict.js
@@ -1,39 +1,39 @@
 var tap = require("../")
   , test = tap.test
 
-test("deepEquals shouldn't care about key order", function (t) {
-  t.deepEqual({ a : 1, b : 2 }, { b : 2, a : 1 })
+test("strictDeepEquals shouldn't care about key order", function (t) {
+  t.strictDeepEqual({ a : 1, b : 2 }, { b : 2, a : 1 })
   t.end()
 })
 
-test("deepEquals shouldn't care about key order recursively", function (t) {
-  t.deepEqual(
+test("strictDeepEquals shouldn't care about key order recursively", function (t) {
+  t.strictDeepEqual(
     { x : { a : 1, b : 2 }, y : { c : 3, d : 4 } },
     { y : { d : 4, c : 3 }, x : { b : 2, a : 1 } }
   )
   t.end()
 })
 
-test("deepEquals shoudn't care about key order but still might", function (t) {
-  t.deepEqual(
+test("strictDeepEquals shoudn't care about key order (but still might)", function (t) {
+  t.strictDeepEqual(
     [ { foo:
         { z: 100
         , y: 200
         , x: 300 } }
     , "bar"
     , 11
-    , { baz: 
+    , { baz:
         { d : 4
         , a: 1
         , b: 2
         , c: 3 } } ]
-  , [ { foo : 
+  , [ { foo :
         { z: 100
         , y: 200
         , x: 300 } }
     , "bar"
     , 11
-    , { baz: 
+    , { baz:
         { a: 1
         , b: 2
         , c: 3
diff --git a/test/deep.js b/test/deep.js
index 52b6110..6235116 100644
--- a/test/deep.js
+++ b/test/deep.js
@@ -1,20 +1,20 @@
 var tap = require("../")
   , test = tap.test
 
-test("deepEquals shouldn't care about key order", function (t) {
-  t.deepEqual({ a : 1, b : 2 }, { b : 2, a : 1 })
+test("deepEquals shouldn't care about key order and types", function (t) {
+  t.deepEqual({ a : 1, b : 2 }, { b : 2, a : "1" })
   t.end()
 })
 
-test("deepEquals shouldn't care about key order recursively", function (t) {
+test("deepEquals shouldn't care about key order recursively and types", function (t) {
   t.deepEqual(
     { x : { a : 1, b : 2 }, y : { c : 3, d : 4 } },
-    { y : { d : 4, c : 3 }, x : { b : 2, a : 1 } }
+    { y : { d : 4, c : 3 }, x : { b : "2", a : "1" } }
   )
   t.end()
 })
 
-test("deepEquals shoudn't care about key order but still might", function (t) {
+test("deepEquals shoudn't care about key order (but still might) and types", function (t) {
   t.deepEqual(
     [ { foo:
         { z: 100
@@ -22,22 +22,22 @@ test("deepEquals shoudn't care about key order but still might", function (t) {
         , x: 300 } }
     , "bar"
     , 11
-    , { baz: 
+    , { baz:
         { d : 4
         , a: 1
         , b: 2
         , c: 3 } } ]
-  , [ { foo : 
+  , [ { foo :
         { z: 100
         , y: 200
         , x: 300 } }
     , "bar"
     , 11
-    , { baz: 
-        { a: 1
-        , b: 2
-        , c: 3
-        , d: 4 } } ]
+    , { baz:
+        { a: "1"
+        , b: "2"
+        , c: "3"
+        , d: "4" } } ]
   )
   t.end()
 });
diff --git a/test/exit-code.js b/test/exit-code.js
new file mode 100644
index 0000000..a2e52de
--- /dev/null
+++ b/test/exit-code.js
@@ -0,0 +1,69 @@
+var spawn = require('child_process').spawn
+var node = process.execPath
+var bin = require.resolve('../bin/tap.js')
+var test = require('../').test
+var path = require('path')
+var fixtures = path.resolve(__dirname, 'fixtures')
+
+test('exit code 1 when tap results show failure', function (t) {
+  t.plan(3)
+
+  t.test('test exits 0, has failures', function (t) {
+    t.plan(2)
+    var file = path.resolve(fixtures, 'fail-zero-exit.js')
+    spawn(node, [bin, file]).on('exit', function (code) {
+      t.equal(code, 1)
+    })
+    spawn(node, [file]).on('exit', function (code) {
+      t.equal(code, 0)
+    })
+  })
+
+  t.test('test exits 1, has failures', function (t) {
+    t.plan(2)
+    var file = path.resolve(fixtures, 'fail-correct-exit.js')
+    spawn(node, [bin, file]).on('exit', function (code) {
+      t.equal(code, 1)
+    })
+    spawn(node, [file]).on('exit', function (code) {
+      t.equal(code, 1)
+    })
+  })
+
+  t.test('test exits 1, has no failures', function (t) {
+    t.plan(2)
+    var file = path.resolve(fixtures, 'fail-exit.js')
+    spawn(node, [bin, file]).on('exit', function (code) {
+      t.equal(code, 1)
+    })
+    spawn(node, [file]).on('exit', function (code) {
+      t.equal(code, 1)
+    })
+  })
+})
+
+test('successes exit 0', function (t) {
+  t.plan(2)
+
+  t.test('test that does nothing, but exits 0', function (t) {
+    t.plan(2)
+    var file = path.resolve(fixtures, 'trivial-success.js')
+    spawn(node, [bin, file]).on('exit', function (code) {
+      t.equal(code, 0)
+    })
+    spawn(node, [file]).on('exit', function (code) {
+      t.equal(code, 0)
+    })
+  })
+
+  t.test('test that succeeds, and exits 0', function (t) {
+    t.plan(2)
+    var file = path.resolve(fixtures, 'success.js')
+    spawn(node, [bin, file]).on('exit', function (code) {
+      t.equal(code, 0)
+    })
+    spawn(node, [file]).on('exit', function (code) {
+      t.equal(code, 0)
+    })
+  })
+})
diff --git a/test/expose-gc-test.js b/test/expose-gc-test.js
index 87377c1..6a91fdc 100644
--- a/test/expose-gc-test.js
+++ b/test/expose-gc-test.js
@@ -1,17 +1,21 @@
 var tap = require("../")
   , fs = require("fs")
   , cp = require("child_process")
+  , path = require("path")
+  , dir = path.resolve(__dirname, "..")
+  , script = path.resolve(dir, "gc-script.js")
+  , opt = { cwd: dir }
 
-fs.writeFileSync("gc-script.js", "console.log(!!global.gc)", "utf8")
+fs.writeFileSync(script, "console.error(!!global.gc)", "utf8")
 
 tap.test("gc test when the gc isn't there", function (t) {
   console.error("gc test")
   t.plan(1)
   console.error("t.plan="+t._plan)
 
-  cp.exec("../bin/tap.js ./gc-script", function (err, stdo, stde) {
+  cp.exec("bin/tap.js ./gc-script.js", opt, function (err, stdo, stde) {
     console.error("assert gc does not exist")
-    t.ok("false", stdo)
+    t.equal(stde, "false\n")
   })
 })
 
@@ -25,9 +29,9 @@ tap.test("gc test when the gc should be there", function (t) {
     t.plan(1)
     console.error("t.plan="+t._plan)
 
-    cp.exec("../bin/tap.js --gc ./gc-script", function (err, stdo, stde) {
+    cp.exec("bin/tap.js --gc ./gc-script.js", opt, function (err, stdo, stde) {
       console.error("assert gc exists")
-      t.ok("true", stdo)
+      t.equal(stde, "true\n")
     })
   })
 
@@ -36,11 +40,14 @@ tap.test("gc test when the gc should be there", function (t) {
     t.plan(1)
     console.error("t.plan="+t._plan)
 
-    cp.exec("../bin/tap.js --expose-gc ./gc-script", function (err, stdo) {
+    cp.exec("bin/tap.js --expose-gc ./gc-script.js", opt, function (err, stdo, stde) {
       console.error("assert gc exists")
-      t.ok("true", stdo)
+      t.equal(stde, "true\n")
     })
   })
 })
 
-fs.unlinkSync("gc-script.js");
+tap.test("cleanup", function (t) {
+  fs.unlinkSync(script)
+  t.end()
+});
diff --git a/test/fixtures/fail-correct-exit.js b/test/fixtures/fail-correct-exit.js
new file mode 100644
index 0000000..d8e52d5
--- /dev/null
+++ b/test/fixtures/fail-correct-exit.js
@@ -0,0 +1,4 @@
+console.log('TAP Version 13')
+console.log('not ok - 1 and it will exit non-zero')
+console.log('1..1')
+process.exit(1)
diff --git a/test/fixtures/fail-exit.js b/test/fixtures/fail-exit.js
new file mode 100644
index 0000000..43866e5
--- /dev/null
+++ b/test/fixtures/fail-exit.js
@@ -0,0 +1,4 @@
+console.log('TAP Version 13')
+console.log('ok - 1 but it will exit non-zero')
+console.log('1..1')
+process.exit(1)
diff --git a/test/fixtures/fail-zero-exit.js b/test/fixtures/fail-zero-exit.js
new file mode 100644
index 0000000..49594b6
--- /dev/null
+++ b/test/fixtures/fail-zero-exit.js
@@ -0,0 +1,4 @@
+console.log('TAP Version 13')
+console.log('not ok - 1 but it will exit zero')
+console.log('1..1')
+process.exit(0)
diff --git a/test/fixtures/success.js b/test/fixtures/success.js
new file mode 100644
index 0000000..c09e43b
--- /dev/null
+++ b/test/fixtures/success.js
@@ -0,0 +1,3 @@
+console.log('TAP Version 13')
+console.log('ok - 1 and exit 0')
+console.log('1..1')
diff --git a/test/fixtures/todo-skip-descriptions.js b/test/fixtures/todo-skip-descriptions.js
new file mode 100644
index 0000000..c1c6ac5
--- /dev/null
+++ b/test/fixtures/todo-skip-descriptions.js
@@ -0,0 +1,4 @@
+console.log('ok - always passes # SKIP skip it, skip it good')
+console.log('not ok - false # SKIP always fails')
+console.log('ok - bonus # TODO remove todo directive')
+console.log('not ok - expected # TODO implement a thing')
diff --git a/test/fixtures/trivial-success.js b/test/fixtures/trivial-success.js
new file mode 100644
index 0000000..092bc2b
--- /dev/null
+++ b/test/fixtures/trivial-success.js
@@ -0,0 +1 @@
+;
diff --git a/test/nested-async.js b/test/nested-async.js
new file mode 100644
index 0000000..ae1cda3
--- /dev/null
+++ b/test/nested-async.js
@@ -0,0 +1,36 @@
+var test = require("../").test
+
+test('Harness async test support', function(t) {
+  t.plan(3);
+
+  t.ok(true, 'sync child A');
+
+  t.test('sync child B', function(tt) {
+    tt.plan(2);
+
+    setTimeout(function(){
+      tt.test('async grandchild A', function(ttt) {
+        ttt.plan(1);
+        ttt.ok(true);
+      });
+    }, 50);
+
+    setTimeout(function() {
+      tt.test('async grandchild B', function(ttt) {
+        ttt.plan(1);
+        ttt.ok(true);
+      });
+    }, 100);
+  });
+
+  setTimeout(function() {
+    t.test('async child', function(tt) {
+      tt.plan(2);
+      tt.ok(true, 'sync grandchild in async child A');
+      tt.test('sync grandchild in async child B', function(ttt) {
+        ttt.plan(1);
+        ttt.ok(true);
+      });
+    });
+  }, 200);
+});
diff --git a/test/nested-test.js b/test/nested-test.js
index 493f13a..d85ff21 100644
--- a/test/nested-test.js
+++ b/test/nested-test.js
@@ -1,6 +1,5 @@
 var tap = require("../"),
-    test = tap.test,
-    util = require('util');
+    test = tap.test;
 
 test("parent", function (t) {
   // TODO: Make grandchildren tests count?
diff --git a/test/not-executed.sh b/test/not-executed.sh
index de46caa..ad00863 100644
--- a/test/not-executed.sh
+++ b/test/not-executed.sh
@@ -2,3 +2,4 @@
 
 echo "1..1"
 echo "not ok 1 File without executable bit should not be run"
+exit 1
diff --git a/test/result-trap.js b/test/result-trap.js
index 1ac600f..6db0af7 100644
--- a/test/result-trap.js
+++ b/test/result-trap.js
@@ -1,18 +1,13 @@
 var tap = require("../")
 
-tap.test("trap result #TODO", function (t0) {
-
-  console.log("not ok 1 result event trapping #TODO")
-  return t0.end()
-
-  t0.plan(3)
+tap.test("trap result", function (t0) {
 
   var t1 = new(tap.Harness)(tap.Test).test()
 
-  t1.plan(1)
-
+  var emitted = false
   t1.on("result", function (res) {
-    if (res.wanted === 4) {
+    if (!emitted) {
+      emitted = true
       t0.equal(res.found, 3)
       t0.equal(res.wanted, 4)
 
diff --git a/test/segv.js b/test/segv.js
index 4a93a04..6d6d779 100644
--- a/test/segv.js
+++ b/test/segv.js
@@ -3,6 +3,7 @@ var Runner = require('../lib/tap-runner.js')
 var TC = require('../lib/tap-consumer.js')
 
 var fs = require('fs')
+var path = require('path')
 var spawn = require('child_process').spawn
 var segv =
     'int main (void) {\n' +
@@ -39,7 +40,7 @@ test('segv', function (t) {
           'exit': null,
           'timedOut': true,
           'signal': process.platform === 'linux' ? 'SIGSEGV' : 'SIGTERM',
-          'command': '"./segv"' }
+          'command': '"' + path.resolve('./segv') + '"' }
       , 'tests 1'
       , 'fail  1' ]
   r.pipe(tc)
diff --git a/test/test-assert-todo-skip.js b/test/test-assert-todo-skip.js
new file mode 100644
index 0000000..281551e
--- /dev/null
+++ b/test/test-assert-todo-skip.js
@@ -0,0 +1,13 @@
+var test = require('../').test
+
+test('not much', function(t) {
+  t.ok(true, 'always passes', {skip: true, explanation: 'skip it good'})
+  t.ok(false, 'false', {skip: true, explanation: 'always fails'})
+  t.ok(true, 'bonus', {todo: true, explanation: 'remove todo directive'})
+  t.ok(false, 'expected', {todo: true, explanation: 'implement a thing'})
+  t.ok(true, 'always passes without explanation', {skip: true})
+  t.ok(false, 'false without explanation', {skip: true})
+  t.ok(true, 'bonus without explanation', {todo: true})
+  t.ok(false, 'expected without explanation', {todo: true})
+  t.end()
+})
diff --git a/test/test-directives.js b/test/test-directives.js
new file mode 100644
index 0000000..5f771ae
--- /dev/null
+++ b/test/test-directives.js
@@ -0,0 +1,48 @@
+var execFile = require('child_process').execFile
+var node = process.execPath
+var bin = require.resolve('../bin/tap.js')
+var test = require('../').test
+var path = require('path')
+var fixtures = path.resolve(__dirname, 'fixtures')
+
+test('captures test descriptions', function (t) {
+  var useConsole = path.resolve(fixtures, 'todo-skip-descriptions.js')
+  var useTap = require.resolve('./test-assert-todo-skip.js')
+
+  t.test('raw TAP > TAP consumer > TAP producer', function(t) {
+    var args = [bin, '--tap', useConsole]
+    execFile(node, args, assertTapDirectives.bind(this, t))
+  })
+
+  t.test('raw TAP > TAP consumer > summary', function(t) {
+    var args = [bin, '--no-tap', useConsole]
+    execFile(node, args, assertDirectivesSummary.bind(this, t))
+  })
+
+  t.test('TAP producer via require("tap")', function(t) {
+    var args = [useTap]
+    execFile(node, args, assertTapDirectives.bind(this, t))
+  })
+
+  function assertTapDirectives(t, err, stdout, stderr) {
+    t.ifError(err, 'overall result is PASS')
+    t.assert(/passes # SKIP skip/i.test(stdout), 'captures ok SKIP')
+    t.assert(/false # SKIP always/i.test(stdout), 'captures not ok SKIP')
+    t.assert(!/skipped: \d+/.test(stdout), 'skip summary not in TAP output')
+    t.assert(/bonus # TODO remove/i.test(stdout), 'captures ok TODO')
+    t.assert(/expected # TODO implem/i.test(stdout), 'captures not ok TODO')
+    t.assert(!/todo: \d+/.test(stdout), 'todo summary is not in TAP output')
+    t.assert(!/undefined/.test(stdout), 'no ugly "undefined" in output')
+    t.end()
+  }
+
+  function assertDirectivesSummary(t, err, stdout, stderr) {
+    t.ifError(err, 'overall result is PASS')
+    t.assert(!/# SKIP/i.test(stdout), 'no SKIP in summary')
+    t.assert(/skipped: 2/.test(stdout), 'skip summary is not in TAP output')
+    t.assert(!/# TODO/i.test(stdout), 'no TODO in summary')
+    t.assert(/todo: 2/.test(stdout), 'todo summary is not in TAP output')
+    t.assert(!/undefined/.test(stdout), 'no ugly "undefined" in output')
+    t.end()
+  }
+})
diff --git a/test/test-skip.js b/test/test-skip.js
new file mode 100644
index 0000000..568da3e
--- /dev/null
+++ b/test/test-skip.js
@@ -0,0 +1,5 @@
+var tap = require('../');
+
+tap.test('does not count as failure', { skip: true }, function(t) {
+  t.end();
+})
diff --git a/test/valid-command.js b/test/valid-command.js
index a54c3d6..f38e270 100644
--- a/test/valid-command.js
+++ b/test/valid-command.js
@@ -14,7 +14,7 @@ test('valid command', function (t) {
     'command': '"' + node + ' t.js"',
     exit: null
   }
-  if (process.platform === 'linux') {
+  if (process.platform === 'linux' && process.version < 'v0.11.0') {
     expectObj.exit = 143
   } else {
     expectObj.signal = 'SIGTERM'

-- 
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