Name: js-handler/node_modules/nodeunit/node_modules/tap/bin/tap.js 
1:
#!/usr/bin/env node
2:
 
3:
var argv = process.argv.slice(2)
4:
  , path = require("path")
5:
  , Runner = require("../lib/tap-runner")
6:
 
7:
  , nopt = require("nopt")
8:
 
9:
  , knownOpts =
10:
    { cover: [path, false]
11:
    , "cover-dir": path
12:
    , stderr: Boolean
13:
    , stdout: Boolean
14:
    , diag: Boolean
15:
    , version: Boolean
16:
    , tap: Boolean
17:
    , timeout: Number
18:
    , gc: Boolean
19:
    }
20:
 
21:
  , shorthands =
22:
    // debugging 1: show stderr
23:
    { d: ["--stderr"]
24:
    // debugging 2: show stderr and tap
25:
    , dd: ["--stderr", "--tap"]
26:
    // debugging 3: show stderr, tap, AND always show diagnostics.
27:
    , ddd: ["--stderr", "--tap", "--diag"]
28:
    , "expose-gc": ["--gc"]
29:
    , g: ["--gc"]
30:
    , e: ["--stderr"]
31:
    , t: ["--timeout"]
32:
    , o: ["--tap"]
33:
    , c: ["--cover"]
34:
    , v: ["--version"]
35:
    , "?": ["--help"]
36:
    , h: ["--help"]
37:
    }
38:
 
39:
  , defaults =
40:
    { cover: "./lib"
41:
    , "cover-dir": "./coverage"
42:
    , stderr: process.env.TAP_STDERR
43:
    , tap: process.env.TAP
44:
    , diag: process.env.TAP_DIAG
45:
    , timeout: +process.env.TAP_TIMEOUT || 30
46:
    , gc: false
47:
    , version: false
48:
    , help: false }
49:
 
50:
  , options = nopt(knownOpts, shorthands)
51:
 
52:
if (options.version) {
53:
  console.log(require("../package.json").version)
54:
  process.exit(0)
55:
}
56:
 
57:
if (options.help) {
58:
  console.log(function(){/*
59:
 
60:
Usage:
61:
    tap <options> <files>
62:
 
63:
    Run the files as tap tests, parse the output, and report the results
64:
 
65:
Options:
66:
 
67:
    --stderr    Print standard error output of tests to standard error.
68:
    --tap       Print raw tap output.
69:
    --diag      Print diagnostic output for passed tests, as well as failed.
70:
                (Implies --tap)
71:
    --gc        Expose the garbage collector to tests.
72:
    --timeout   Maximum time to wait for a subtest, in seconds. Default: 30
73:
    --version   Print the version of node tap.
74:
    --help      Print this help.
75:
 
76:
Please report bugs!  https://github.com/isaacs/node-tap/issues
77:
 
78:
*/}.toString().split(/\n/).slice(1, -1).join("\n"))
79:
  process.exit(0)
80:
}
81:
 
82:
 
83:
Object.keys(defaults).forEach(function (k) {
84:
  if (!options.hasOwnProperty(k)) options[k] = defaults[k]
85:
})
86:
 
87:
// other tests that might rely on these
88:
if (options.diag) process.env.TAP_DIAG = true
89:
if (options.tap) process.env.TAP = true
90:
if (options.timeout) process.env.TAP_TIMEOUT = options.timeout
91:
 
92:
var r = new Runner(options)
93:
  , TapProducer = require("../lib/tap-producer")
94:
 
95:
if (options.tap || options.diag) {
96:
  r.pipe(process.stdout)
97:
} else {
98:
  r.on("file", function (file, results, details) {
99:
    var s = (details.ok ? "" : "not ") + "ok "+results.name
100:
      , n = details.pass + "/" + details.testsTotal
101:
      , dots = new Array(Math.max(1, 60 - s.length - n.length)).join(".")
102:
    console.log("%s %s %s", s, dots, n)
103:
    if (details.ok) {
104:
      if (details.skip) {
105:
        console.log("  skipped: %s", details.skipTotal)
106:
      }
107:
    } else {
108:
      // console.error(details)
109:
      console.log("    Command: %s", results.command)
110:
      console.log("    " + TapProducer.encode(details.list)
111:
                  .split(/\n/).join("\n    "))
112:
    }
113:
  })
114:
  r.on("end", function () {
115:
    //console.log(r)
116:
    var s = "total"
117:
      , n = r.results.pass + "/" + r.results.testsTotal
118:
      , dots = new Array(60 - s.length - n.length).join(".")
119:
      , ok = r.results.ok ? "ok" : "not ok"
120:
    console.log("%s %s %s\n\n%s", s, dots, n, ok)
121:
    if (r.doCoverage) {
122:
      console.error( "\nCoverage: %s\n"
123:
                   , path.resolve(r.coverageOutDir, "index.html") )
124:
    }
125:
  })
126:
}
127:
 
128:
 
129:
 
130:
r.on("end", function () {
131:
  process.exit(r.results.tests - r.results.pass)
132:
})