Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update nodeunit to 0.8.6 #118

Merged
merged 1 commit into from

1 participant

@muffinresearch

No description provided.

@muffinresearch muffinresearch merged commit 9ffc793 into mozilla:master
@muffinresearch muffinresearch deleted the muffinresearch:update-nodeunit branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2014
  1. @muffinresearch
This page is out of date. Refresh to see the latest.
View
14 node_modules/nodeunit/lib/reporters/index.js
@@ -1,3 +1,15 @@
+// This is a hack to make browserify skip tap
+var tap;
+try {
+ tap = require('./' + 'tap');
+} catch (ex) {
+ tap = {
+ run: function() {
+ throw new Error('Sorry, tap reporter not available');
+ }
+ };
+}
+
module.exports = {
'junit': require('./junit'),
'default': require('./default'),
@@ -6,7 +18,7 @@ module.exports = {
'html': require('./html'),
'eclipse': require('./eclipse'),
'machineout': require('./machineout'),
- 'tap': require('./tap'),
+ 'tap': tap,
'nested': require('./nested'),
'verbose' : require('./verbose'),
'lcov' : require('./lcov')
View
6 node_modules/nodeunit/lib/utils.js
@@ -24,17 +24,17 @@ var extensions = [ 'js' ]; // js is always supported: add it unconditionally
var extensionPattern;
try {
- require('coffee-script');
+ require('coffee' + '-script');
extensions.push('coffee');
} catch (e) { }
try {
- require('iced-coffee-script');
+ require('iced-coffee' + '-script');
extensions.push('iced');
} catch (e) { }
try {
- require('streamline').register();
+ require('stream' + 'line').register();
extensions.push('_coffee');
extensions.push('_js');
} catch (e) { }
View
130 node_modules/nodeunit/node_modules/tap/node_modules/glob/glob.js
@@ -76,6 +76,7 @@ function globSync (pattern, options) {
return glob(pattern, options)
}
+this._processingEmitQueue = false
glob.Glob = Glob
inherits(Glob, EE)
@@ -98,9 +99,13 @@ function Glob (pattern, options, cb) {
options = options || {}
+ this._endEmitted = false
this.EOF = {}
this._emitQueue = []
+ this.paused = false
+ this._processingEmitQueue = false
+
this.maxDepth = options.maxDepth || 1000
this.maxLength = options.maxLength || Infinity
this.cache = options.cache || {}
@@ -214,10 +219,15 @@ Glob.prototype._finish = function () {
all = all.sort(this.nocase ? alphasorti : alphasort)
}
+ if (this.mark) {
+ // at *some* point we statted all of these
+ all = all.map(this._mark, this)
+ }
+
this.log("emitting end", all)
this.EOF = this.found = all
- this.emitMatch(this.EOF, -1)
+ this.emitMatch(this.EOF)
}
function alphasorti (a, b) {
@@ -230,29 +240,6 @@ function alphasort (a, b) {
return a > b ? 1 : a < b ? -1 : 0
}
-Glob.prototype.abort = function () {
- this.aborted = true
- this.emit("abort")
-}
-
-Glob.prototype.pause = function () {
- if (this.paused) return
- if (this.sync)
- this.emit("error", new Error("Can't pause/resume sync glob"))
- this.paused = true
- this.emit("pause")
-}
-
-Glob.prototype.resume = function () {
- if (!this.paused) return
- if (this.sync)
- this.emit("error", new Error("Can't pause/resume sync glob"))
- this.paused = false
- this.emit("resume")
- this._processEmitQueue()
- //process.nextTick(this.emit.bind(this, "resume"))
-}
-
Glob.prototype._mark = function (p) {
var c = this.cache[p]
var m = p
@@ -274,45 +261,92 @@ Glob.prototype._mark = function (p) {
return m
}
-Glob.prototype._pushMatch = function(m, index) {
- if (this.mark && m !== this.EOF)
- m = this._mark(m)
+Glob.prototype.abort = function () {
+ this.aborted = true
+ this.emit("abort")
+}
- if (m !== this.EOF) {
- this.matches[index] = this.matches[index] || {}
- this.matches[index][m] = true
- }
+Glob.prototype.pause = function () {
+ if (this.paused) return
+ if (this.sync)
+ this.emit("error", new Error("Can't pause/resume sync glob"))
+ this.paused = true
+ this.emit("pause")
+}
- this._emitQueue.push(m)
+Glob.prototype.resume = function () {
+ if (!this.paused) return
+ if (this.sync)
+ this.emit("error", new Error("Can't pause/resume sync glob"))
+ this.paused = false
+ this.emit("resume")
this._processEmitQueue()
+ //process.nextTick(this.emit.bind(this, "resume"))
}
-Glob.prototype.emitMatch = function (m, index) {
- if ((!this.stat && !this.mark) || this.statCache[m] || m === this.EOF) {
- this._pushMatch(m, index)
- } else {
- this._stat(m, function(exists, isDir) {
- if (exists)
- this._pushMatch(m, index)
- })
- }
+Glob.prototype.emitMatch = function (m) {
+ this.log('emitMatch', m)
+ this._emitQueue.push(m)
+ this._processEmitQueue()
}
Glob.prototype._processEmitQueue = function (m) {
+ this.log("pEQ paused=%j processing=%j m=%j", this.paused,
+ this._processingEmitQueue, m)
+ var done = false
while (!this._processingEmitQueue &&
!this.paused) {
this._processingEmitQueue = true
var m = this._emitQueue.shift()
+ this.log(">processEmitQueue", m === this.EOF ? ":EOF:" : m)
if (!m) {
+ this.log(">processEmitQueue, falsey m")
this._processingEmitQueue = false
break
}
- this.log('emit!', m === this.EOF ? "end" : "match")
+ if (m === this.EOF || !(this.mark && !this.stat)) {
+ this.log("peq: unmarked, or eof")
+ next.call(this, 0, false)
+ } else if (this.statCache[m]) {
+ var sc = this.statCache[m]
+ var exists
+ if (sc)
+ exists = sc.isDirectory() ? 2 : 1
+ this.log("peq: stat cached")
+ next.call(this, exists, exists === 2)
+ } else {
+ this.log("peq: _stat, then next")
+ this._stat(m, next)
+ }
- this.emit(m === this.EOF ? "end" : "match", m)
- this._processingEmitQueue = false
+ function next(exists, isDir) {
+ this.log("next", m, exists, isDir)
+ var ev = m === this.EOF ? "end" : "match"
+
+ // "end" can only happen once.
+ assert(!this._endEmitted)
+ if (ev === "end")
+ this._endEmitted = true
+
+ if (exists) {
+ // Doesn't mean it necessarily doesn't exist, it's possible
+ // we just didn't check because we don't care that much, or
+ // this is EOF anyway.
+ if (isDir && !m.match(/\/$/)) {
+ m = m + "/"
+ } else if (!isDir && m.match(/\/$/)) {
+ m = m.replace(/\/+$/, "")
+ }
+ }
+ this.log("emit", ev, m)
+ this.emit(ev, m)
+ this._processingEmitQueue = false
+ if (done && m !== this.EOF && !this.paused)
+ this._processEmitQueue()
+ }
}
+ done = true
}
Glob.prototype._process = function (pattern, depth, index, cb_) {
@@ -367,7 +401,9 @@ Glob.prototype._process = function (pattern, depth, index, cb_) {
if (process.platform === "win32")
prefix = prefix.replace(/\\/g, "/")
- this.emitMatch(prefix, index)
+ this.matches[index] = this.matches[index] || {}
+ this.matches[index][prefix] = true
+ this.emitMatch(prefix)
}
return cb()
})
@@ -481,7 +517,9 @@ Glob.prototype._process = function (pattern, depth, index, cb_) {
if (process.platform === "win32")
e = e.replace(/\\/g, "/")
- this.emitMatch(e, index)
+ this.matches[index] = this.matches[index] || {}
+ this.matches[index][e] = true
+ this.emitMatch(e)
}, this)
return cb.call(this)
}
View
7 node_modules/nodeunit/node_modules/tap/node_modules/glob/package.json
@@ -6,7 +6,7 @@
},
"name": "glob",
"description": "a little globber",
- "version": "3.2.8",
+ "version": "3.2.9",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-glob.git"
@@ -25,7 +25,8 @@
"rimraf": "1"
},
"scripts": {
- "test": "tap test/*.js"
+ "test": "tap test/*.js",
+ "test-regen": "TEST_REGEN=1 node test/00-setup.js"
},
"license": "BSD",
"readme": "# Glob\n\nMatch files using the patterns the shell uses, like stars and stuff.\n\nThis is a glob implementation in JavaScript. It uses the `minimatch`\nlibrary to do its matching.\n\n## Attention: node-glob users!\n\nThe API has changed dramatically between 2.x and 3.x. This library is\nnow 100% JavaScript, and the integer flags have been replaced with an\noptions object.\n\nAlso, there's an event emitter class, proper tests, and all the other\nthings you've come to expect from node modules.\n\nAnd best of all, no compilation!\n\n## Usage\n\n```javascript\nvar glob = require(\"glob\")\n\n// options is optional\nglob(\"**/*.js\", options, function (er, files) {\n // files is an array of filenames.\n // If the `nonull` option is set, and nothing\n // was found, then files is [\"**/*.js\"]\n // er is an error object or null.\n})\n```\n\n## Features\n\nPlease see the [minimatch\ndocumentation](https://github.com/isaacs/minimatch) for more details.\n\nSupports these glob features:\n\n* Brace Expansion\n* Extended glob matching\n* \"Globstar\" `**` matching\n\nSee:\n\n* `man sh`\n* `man bash`\n* `man 3 fnmatch`\n* `man 5 gitignore`\n* [minimatch documentation](https://github.com/isaacs/minimatch)\n\n## glob(pattern, [options], cb)\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* `cb` {Function}\n * `err` {Error | null}\n * `matches` {Array<String>} filenames found matching the pattern\n\nPerform an asynchronous glob search.\n\n## glob.sync(pattern, [options])\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* return: {Array<String>} filenames found matching the pattern\n\nPerform a synchronous glob search.\n\n## Class: glob.Glob\n\nCreate a Glob object by instanting the `glob.Glob` class.\n\n```javascript\nvar Glob = require(\"glob\").Glob\nvar mg = new Glob(pattern, options, cb)\n```\n\nIt's an EventEmitter, and starts walking the filesystem to find matches\nimmediately.\n\n### new glob.Glob(pattern, [options], [cb])\n\n* `pattern` {String} pattern to search for\n* `options` {Object}\n* `cb` {Function} Called when an error occurs, or matches are found\n * `err` {Error | null}\n * `matches` {Array<String>} filenames found matching the pattern\n\nNote that if the `sync` flag is set in the options, then matches will\nbe immediately available on the `g.found` member.\n\n### Properties\n\n* `minimatch` The minimatch object that the glob uses.\n* `options` The options object passed in.\n* `error` The error encountered. When an error is encountered, the\n glob object is in an undefined state, and should be discarded.\n* `aborted` Boolean which is set to true when calling `abort()`. There\n is no way at this time to continue a glob search after aborting, but\n you can re-use the statCache to avoid having to duplicate syscalls.\n* `statCache` Collection of all the stat results the glob search\n performed.\n* `cache` Convenience object. Each field has the following possible\n values:\n * `false` - Path does not exist\n * `true` - Path exists\n * `1` - Path exists, and is not a directory\n * `2` - Path exists, and is a directory\n * `[file, entries, ...]` - Path exists, is a directory, and the\n array value is the results of `fs.readdir`\n\n### Events\n\n* `end` When the matching is finished, this is emitted with all the\n matches found. If the `nonull` option is set, and no match was found,\n then the `matches` list contains the original pattern. The matches\n are sorted, unless the `nosort` flag is set.\n* `match` Every time a match is found, this is emitted with the matched.\n* `error` Emitted when an unexpected error is encountered, or whenever\n any fs error occurs if `options.strict` is set.\n* `abort` When `abort()` is called, this event is raised.\n\n### Methods\n\n* `abort` Stop the search.\n\n### Options\n\nAll the options that can be passed to Minimatch can also be passed to\nGlob to change pattern matching behavior. Also, some have been added,\nor have glob-specific ramifications.\n\nAll options are false by default, unless otherwise noted.\n\nAll options are added to the glob object, as well.\n\n* `cwd` The current working directory in which to search. Defaults\n to `process.cwd()`.\n* `root` The place where patterns starting with `/` will be mounted\n onto. Defaults to `path.resolve(options.cwd, \"/\")` (`/` on Unix\n systems, and `C:\\` or some such on Windows.)\n* `dot` Include `.dot` files in normal matches and `globstar` matches.\n Note that an explicit dot in a portion of the pattern will always\n match dot files.\n* `nomount` By default, a pattern starting with a forward-slash will be\n \"mounted\" onto the root setting, so that a valid filesystem path is\n returned. Set this flag to disable that behavior.\n* `mark` Add a `/` character to directory matches. Note that this\n requires additional stat calls.\n* `nosort` Don't sort the results.\n* `stat` Set to true to stat *all* results. This reduces performance\n somewhat, and is completely unnecessary, unless `readdir` is presumed\n to be an untrustworthy indicator of file existence. It will cause\n ELOOP to be triggered one level sooner in the case of cyclical\n symbolic links.\n* `silent` When an unusual error is encountered\n when attempting to read a directory, a warning will be printed to\n stderr. Set the `silent` option to true to suppress these warnings.\n* `strict` When an unusual error is encountered\n when attempting to read a directory, the process will just continue on\n in search of other matches. Set the `strict` option to raise an error\n in these cases.\n* `cache` See `cache` property above. Pass in a previously generated\n cache object to save some fs calls.\n* `statCache` A cache of results of filesystem information, to prevent\n unnecessary stat calls. While it should not normally be necessary to\n set this, you may pass the statCache from one glob() call to the\n options object of another, if you know that the filesystem will not\n change between calls. (See \"Race Conditions\" below.)\n* `sync` Perform a synchronous glob search.\n* `nounique` In some cases, brace-expanded patterns can result in the\n same file showing up multiple times in the result set. By default,\n this implementation prevents duplicates in the result set.\n Set this flag to disable that behavior.\n* `nonull` Set to never return an empty set, instead returning a set\n containing the pattern itself. This is the default in glob(3).\n* `nocase` Perform a case-insensitive match. Note that case-insensitive\n filesystems will sometimes result in glob returning results that are\n case-insensitively matched anyway, since readdir and stat will not\n raise an error.\n* `debug` Set to enable debug logging in minimatch and glob.\n* `globDebug` Set to enable debug logging in glob, but not minimatch.\n\n## Comparisons to other fnmatch/glob implementations\n\nWhile strict compliance with the existing standards is a worthwhile\ngoal, some discrepancies exist between node-glob and other\nimplementations, and are intentional.\n\nIf the pattern starts with a `!` character, then it is negated. Set the\n`nonegate` flag to suppress this behavior, and treat leading `!`\ncharacters normally. This is perhaps relevant if you wish to start the\npattern with a negative extglob pattern like `!(a|B)`. Multiple `!`\ncharacters at the start of a pattern will negate the pattern multiple\ntimes.\n\nIf a pattern starts with `#`, then it is treated as a comment, and\nwill not match anything. Use `\\#` to match a literal `#` at the\nstart of a line, or set the `nocomment` flag to suppress this behavior.\n\nThe double-star character `**` is supported by default, unless the\n`noglobstar` flag is set. This is supported in the manner of bsdglob\nand bash 4.1, where `**` only has special significance if it is the only\nthing in a path part. That is, `a/**/b` will match `a/x/y/b`, but\n`a/**b` will not.\n\nIf an escaped pattern has no matches, and the `nonull` flag is set,\nthen glob returns the pattern as-provided, rather than\ninterpreting the character escapes. For example,\n`glob.match([], \"\\\\*a\\\\?\")` will return `\"\\\\*a\\\\?\"` rather than\n`\"*a?\"`. This is akin to setting the `nullglob` option in bash, except\nthat it does not resolve escaped pattern characters.\n\nIf brace expansion is not disabled, then it is performed before any\nother interpretation of the glob pattern. Thus, a pattern like\n`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded\n**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are\nchecked for validity. Since those two are valid, matching proceeds.\n\n## Windows\n\n**Please only use forward-slashes in glob expressions.**\n\nThough windows uses either `/` or `\\` as its path separator, only `/`\ncharacters are used by this glob implementation. You must use\nforward-slashes **only** in glob expressions. Back-slashes will always\nbe interpreted as escape characters, not path separators.\n\nResults from absolute patterns such as `/foo/*` are mounted onto the\nroot setting using `path.join`. On windows, this will by default result\nin `/foo/*` matching `C:\\foo\\bar.txt`.\n\n## Race Conditions\n\nGlob searching, by its very nature, is susceptible to race conditions,\nsince it relies on directory walking and such.\n\nAs a result, it is possible that a file that exists when glob looks for\nit may have been deleted or modified by the time it returns the result.\n\nAs part of its internal implementation, this program caches all stat\nand readdir calls that it makes, in order to cut down on system\noverhead. However, this also makes it even more susceptible to races,\nespecially if the cache or statCache objects are reused between glob\ncalls.\n\nUsers are thus advised not to use a glob result as a guarantee of\nfilesystem state in the face of rapid changes. For the vast majority\nof operations, this is never a problem.\n",
@@ -34,6 +35,6 @@
"url": "https://github.com/isaacs/node-glob/issues"
},
"homepage": "https://github.com/isaacs/node-glob",
- "_id": "glob@3.2.8",
+ "_id": "glob@3.2.9",
"_from": "glob@~3.2.1"
}
View
1  node_modules/nodeunit/node_modules/tap/node_modules/glob/test/bash-results.json
@@ -298,6 +298,7 @@
"./test/new-glob-optional-options.js",
"./test/nocase-nomagic.js",
"./test/pause-resume.js",
+ "./test/readme-issue.js",
"./test/root-nomount.js",
"./test/root.js",
"./test/stat.js",
View
36 node_modules/nodeunit/node_modules/tap/node_modules/glob/test/mark.js
@@ -2,6 +2,42 @@ var test = require("tap").test
var glob = require('../')
process.chdir(__dirname)
+// expose timing issues
+var lag = 5
+glob.Glob.prototype._stat = function(o) { return function(f, cb) {
+ var args = arguments
+ setTimeout(function() {
+ o.call(this, f, cb)
+ }.bind(this), lag += 5)
+}}(glob.Glob.prototype._stat)
+
+
+test("mark, with **", function (t) {
+ glob("a/*b*/**", {mark: true}, function (er, results) {
+ if (er)
+ throw er
+ var expect =
+ [ 'a/abcdef/',
+ 'a/abcdef/g/',
+ 'a/abcdef/g/h',
+ 'a/abcfed/',
+ 'a/abcfed/g/',
+ 'a/abcfed/g/h',
+ 'a/b/',
+ 'a/b/c/',
+ 'a/b/c/d',
+ 'a/bc/',
+ 'a/bc/e/',
+ 'a/bc/e/f',
+ 'a/cb/',
+ 'a/cb/e/',
+ 'a/cb/e/f' ]
+
+ t.same(results, expect)
+ t.end()
+ })
+})
+
test("mark, no / on pattern", function (t) {
glob("a/*", {mark: true}, function (er, results) {
if (er)
View
36 node_modules/nodeunit/node_modules/tap/node_modules/glob/test/readme-issue.js
@@ -0,0 +1,36 @@
+var test = require("tap").test
+var glob = require("../")
+
+var mkdirp = require("mkdirp")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var dir = __dirname + "/package"
+
+test("setup", function (t) {
+ mkdirp.sync(dir)
+ fs.writeFileSync(dir + "/package.json", "{}", "ascii")
+ fs.writeFileSync(dir + "/README", "x", "ascii")
+ t.pass("setup done")
+ t.end()
+})
+
+test("glob", function (t) {
+ var opt = {
+ cwd: dir,
+ nocase: true,
+ mark: true
+ }
+
+ glob("README?(.*)", opt, function (er, files) {
+ if (er)
+ throw er
+ t.same(files, ["README"])
+ t.end()
+ })
+})
+
+test("cleanup", function (t) {
+ rimraf.sync(dir)
+ t.pass("clean")
+ t.end()
+})
View
8 node_modules/nodeunit/node_modules/tap/node_modules/nopt/README.md
@@ -61,12 +61,12 @@ $ node my-program.js -fp --foofoo
$ node my-program.js --foofoo -- -fp # -- stops the flag parsing.
{ foo: "Mr. Foo", argv: { remain: ["-fp"] } }
-$ node my-program.js --blatzk 1000 -fp # unknown opts are ok.
-{ blatzk: 1000, flag: true, pick: true }
-
-$ node my-program.js --blatzk true -fp # but they need a value
+$ node my-program.js --blatzk -fp # unknown opts are ok.
{ blatzk: true, flag: true, pick: true }
+$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value
+{ blatzk: 1000, flag: true, pick: true }
+
$ node my-program.js --no-blatzk -fp # unless they start with "no-"
{ blatzk: false, flag: true, pick: true }
View
213 node_modules/nodeunit/node_modules/tap/node_modules/nopt/lib/nopt.js
@@ -125,6 +125,7 @@ function validateString (data, k, val) {
}
function validatePath (data, k, val) {
+ if (val === true) return false
data[k] = path.resolve(String(val))
return true
}
@@ -327,6 +328,9 @@ function parse (args, data, remain, types, shorthands) {
continue
}
+ if (types[arg] === String && la === undefined)
+ la = ""
+
if (la && la.match(/^-{2,}$/)) {
la = undefined
i --
@@ -401,212 +405,3 @@ function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
return shorthands[arg]
}
-
-if (module === require.main) {
-var assert = require("assert")
- , util = require("util")
-
- , shorthands =
- { s : ["--loglevel", "silent"]
- , d : ["--loglevel", "info"]
- , dd : ["--loglevel", "verbose"]
- , ddd : ["--loglevel", "silly"]
- , noreg : ["--no-registry"]
- , reg : ["--registry"]
- , "no-reg" : ["--no-registry"]
- , silent : ["--loglevel", "silent"]
- , verbose : ["--loglevel", "verbose"]
- , h : ["--usage"]
- , H : ["--usage"]
- , "?" : ["--usage"]
- , help : ["--usage"]
- , v : ["--version"]
- , f : ["--force"]
- , desc : ["--description"]
- , "no-desc" : ["--no-description"]
- , "local" : ["--no-global"]
- , l : ["--long"]
- , p : ["--parseable"]
- , porcelain : ["--parseable"]
- , g : ["--global"]
- }
-
- , types =
- { aoa: Array
- , nullstream: [null, Stream]
- , date: Date
- , str: String
- , browser : String
- , cache : path
- , color : ["always", Boolean]
- , depth : Number
- , description : Boolean
- , dev : Boolean
- , editor : path
- , force : Boolean
- , global : Boolean
- , globalconfig : path
- , group : [String, Number]
- , gzipbin : String
- , logfd : [Number, Stream]
- , loglevel : ["silent","win","error","warn","info","verbose","silly"]
- , long : Boolean
- , "node-version" : [false, String]
- , npaturl : url
- , npat : Boolean
- , "onload-script" : [false, String]
- , outfd : [Number, Stream]
- , parseable : Boolean
- , pre: Boolean
- , prefix: path
- , proxy : url
- , "rebuild-bundle" : Boolean
- , registry : url
- , searchopts : String
- , searchexclude: [null, String]
- , shell : path
- , t: [Array, String]
- , tag : String
- , tar : String
- , tmp : path
- , "unsafe-perm" : Boolean
- , usage : Boolean
- , user : String
- , username : String
- , userconfig : path
- , version : Boolean
- , viewer: path
- , _exit : Boolean
- }
-
-; [["-v", {version:true}, []]
- ,["---v", {version:true}, []]
- ,["ls -s --no-reg connect -d",
- {loglevel:"info",registry:null},["ls","connect"]]
- ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]]
- ,["ls --registry blargle", {}, ["ls"]]
- ,["--no-registry", {registry:null}, []]
- ,["--no-color true", {color:false}, []]
- ,["--no-color false", {color:true}, []]
- ,["--no-color", {color:false}, []]
- ,["--color false", {color:false}, []]
- ,["--color --logfd 7", {logfd:7,color:true}, []]
- ,["--color=true", {color:true}, []]
- ,["--logfd=10", {logfd:10}, []]
- ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]]
- ,["--tmp=tmp -tar=gtar",
- {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]]
- ,["--logfd x", {}, []]
- ,["a -true -- -no-false", {true:true},["a","-no-false"]]
- ,["a -no-false", {false:false},["a"]]
- ,["a -no-no-true", {true:true}, ["a"]]
- ,["a -no-no-no-false", {false:false}, ["a"]]
- ,["---NO-no-No-no-no-no-nO-no-no"+
- "-No-no-no-no-no-no-no-no-no"+
- "-no-no-no-no-NO-NO-no-no-no-no-no-no"+
- "-no-body-can-do-the-boogaloo-like-I-do"
- ,{"body-can-do-the-boogaloo-like-I-do":false}, []]
- ,["we are -no-strangers-to-love "+
- "--you-know=the-rules --and=so-do-i "+
- "---im-thinking-of=a-full-commitment "+
- "--no-you-would-get-this-from-any-other-guy "+
- "--no-gonna-give-you-up "+
- "-no-gonna-let-you-down=true "+
- "--no-no-gonna-run-around false "+
- "--desert-you=false "+
- "--make-you-cry false "+
- "--no-tell-a-lie "+
- "--no-no-and-hurt-you false"
- ,{"strangers-to-love":false
- ,"you-know":"the-rules"
- ,"and":"so-do-i"
- ,"you-would-get-this-from-any-other-guy":false
- ,"gonna-give-you-up":false
- ,"gonna-let-you-down":false
- ,"gonna-run-around":false
- ,"desert-you":false
- ,"make-you-cry":false
- ,"tell-a-lie":false
- ,"and-hurt-you":false
- },["we", "are"]]
- ,["-t one -t two -t three"
- ,{t: ["one", "two", "three"]}
- ,[]]
- ,["-t one -t null -t three four five null"
- ,{t: ["one", "null", "three"]}
- ,["four", "five", "null"]]
- ,["-t foo"
- ,{t:["foo"]}
- ,[]]
- ,["--no-t"
- ,{t:["false"]}
- ,[]]
- ,["-no-no-t"
- ,{t:["true"]}
- ,[]]
- ,["-aoa one -aoa null -aoa 100"
- ,{aoa:["one", null, 100]}
- ,[]]
- ,["-str 100"
- ,{str:"100"}
- ,[]]
- ,["--color always"
- ,{color:"always"}
- ,[]]
- ,["--no-nullstream"
- ,{nullstream:null}
- ,[]]
- ,["--nullstream false"
- ,{nullstream:null}
- ,[]]
- ,["--notadate=2011-01-25"
- ,{notadate: "2011-01-25"}
- ,[]]
- ,["--date 2011-01-25"
- ,{date: new Date("2011-01-25")}
- ,[]]
- ,["-cl 1"
- ,{config: true, length: 1}
- ,[]
- ,{config: Boolean, length: Number, clear: Boolean}
- ,{c: "--config", l: "--length"}]
- ,["--acount bla"
- ,{"acount":true}
- ,["bla"]
- ,{account: Boolean, credentials: Boolean, options: String}
- ,{a:"--account", c:"--credentials",o:"--options"}]
- ,["--clear"
- ,{clear:true}
- ,[]
- ,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean}
- ,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}]
- ,["--file -"
- ,{"file":"-"}
- ,[]
- ,{file:String}
- ,{}]
- ,["--file -"
- ,{"file":true}
- ,["-"]
- ,{file:Boolean}
- ,{}]
- ].forEach(function (test) {
- var argv = test[0].split(/\s+/)
- , opts = test[1]
- , rem = test[2]
- , actual = nopt(test[3] || types, test[4] || shorthands, argv, 0)
- , parsed = actual.argv
- delete actual.argv
- console.log(util.inspect(actual, false, 2, true), parsed.remain)
- for (var i in opts) {
- var e = JSON.stringify(opts[i])
- , a = JSON.stringify(actual[i] === undefined ? null : actual[i])
- if (e && typeof e === "object") {
- assert.deepEqual(e, a)
- } else {
- assert.equal(e, a)
- }
- }
- assert.deepEqual(rem, parsed.remain)
- })
-}
View
11 node_modules/nodeunit/node_modules/tap/node_modules/nopt/package.json
@@ -1,6 +1,6 @@
{
"name": "nopt",
- "version": "2.1.2",
+ "version": "2.2.0",
"description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
"author": {
"name": "Isaac Z. Schlueter",
@@ -9,7 +9,7 @@
},
"main": "lib/nopt.js",
"scripts": {
- "test": "node lib/nopt.js"
+ "test": "tap test/*.js"
},
"repository": {
"type": "git",
@@ -25,12 +25,15 @@
"dependencies": {
"abbrev": "1"
},
- "readme": "If you want to write an option parser, and have it be good, there are\ntwo ways to do it. The Right Way, and the Wrong Way.\n\nThe Wrong Way is to sit down and write an option parser. We've all done\nthat.\n\nThe Right Way is to write some complex configurable program with so many\noptions that you go half-insane just trying to manage them all, and put\nit off with duct-tape solutions until you see exactly to the core of the\nproblem, and finally snap and write an awesome option parser.\n\nIf you want to write an option parser, don't write an option parser.\nWrite a package manager, or a source control system, or a service\nrestarter, or an operating system. You probably won't end up with a\ngood one of those, but if you don't give up, and you are relentless and\ndiligent enough in your procrastination, you may just end up with a very\nnice option parser.\n\n## USAGE\n\n // my-program.js\n var nopt = require(\"nopt\")\n , Stream = require(\"stream\").Stream\n , path = require(\"path\")\n , knownOpts = { \"foo\" : [String, null]\n , \"bar\" : [Stream, Number]\n , \"baz\" : path\n , \"bloo\" : [ \"big\", \"medium\", \"small\" ]\n , \"flag\" : Boolean\n , \"pick\" : Boolean\n , \"many\" : [String, Array]\n }\n , shortHands = { \"foofoo\" : [\"--foo\", \"Mr. Foo\"]\n , \"b7\" : [\"--bar\", \"7\"]\n , \"m\" : [\"--bloo\", \"medium\"]\n , \"p\" : [\"--pick\"]\n , \"f\" : [\"--flag\"]\n }\n // everything is optional.\n // knownOpts and shorthands default to {}\n // arg list defaults to process.argv\n // slice defaults to 2\n , parsed = nopt(knownOpts, shortHands, process.argv, 2)\n console.log(parsed)\n\nThis would give you support for any of the following:\n\n```bash\n$ node my-program.js --foo \"blerp\" --no-flag\n{ \"foo\" : \"blerp\", \"flag\" : false }\n\n$ node my-program.js ---bar 7 --foo \"Mr. Hand\" --flag\n{ bar: 7, foo: \"Mr. Hand\", flag: true }\n\n$ node my-program.js --foo \"blerp\" -f -----p\n{ foo: \"blerp\", flag: true, pick: true }\n\n$ node my-program.js -fp --foofoo\n{ foo: \"Mr. Foo\", flag: true, pick: true }\n\n$ node my-program.js --foofoo -- -fp # -- stops the flag parsing.\n{ foo: \"Mr. Foo\", argv: { remain: [\"-fp\"] } }\n\n$ node my-program.js --blatzk 1000 -fp # unknown opts are ok.\n{ blatzk: 1000, flag: true, pick: true }\n\n$ node my-program.js --blatzk true -fp # but they need a value\n{ blatzk: true, flag: true, pick: true }\n\n$ node my-program.js --no-blatzk -fp # unless they start with \"no-\"\n{ blatzk: false, flag: true, pick: true }\n\n$ node my-program.js --baz b/a/z # known paths are resolved.\n{ baz: \"/Users/isaacs/b/a/z\" }\n\n# if Array is one of the types, then it can take many\n# values, and will always be an array. The other types provided\n# specify what types are allowed in the list.\n\n$ node my-program.js --many 1 --many null --many foo\n{ many: [\"1\", \"null\", \"foo\"] }\n\n$ node my-program.js --many foo\n{ many: [\"foo\"] }\n```\n\nRead the tests at the bottom of `lib/nopt.js` for more examples of\nwhat this puppy can do.\n\n## Types\n\nThe following types are supported, and defined on `nopt.typeDefs`\n\n* String: A normal string. No parsing is done.\n* path: A file system path. Gets resolved against cwd if not absolute.\n* url: A url. If it doesn't parse, it isn't accepted.\n* Number: Must be numeric.\n* Date: Must parse as a date. If it does, and `Date` is one of the options,\n then it will return a Date object, not a string.\n* Boolean: Must be either `true` or `false`. If an option is a boolean,\n then it does not need a value, and its presence will imply `true` as\n the value. To negate boolean flags, do `--no-whatever` or `--whatever\n false`\n* NaN: Means that the option is strictly not allowed. Any value will\n fail.\n* Stream: An object matching the \"Stream\" class in node. Valuable\n for use when validating programmatically. (npm uses this to let you\n supply any WriteStream on the `outfd` and `logfd` config options.)\n* Array: If `Array` is specified as one of the types, then the value\n will be parsed as a list of options. This means that multiple values\n can be specified, and that the value will always be an array.\n\nIf a type is an array of values not on this list, then those are\nconsidered valid values. For instance, in the example above, the\n`--bloo` option can only be one of `\"big\"`, `\"medium\"`, or `\"small\"`,\nand any other value will be rejected.\n\nWhen parsing unknown fields, `\"true\"`, `\"false\"`, and `\"null\"` will be\ninterpreted as their JavaScript equivalents, and numeric values will be\ninterpreted as a number.\n\nYou can also mix types and values, or multiple types, in a list. For\ninstance `{ blah: [Number, null] }` would allow a value to be set to\neither a Number or null. When types are ordered, this implies a\npreference, and the first type that can be used to properly interpret\nthe value will be used.\n\nTo define a new type, add it to `nopt.typeDefs`. Each item in that\nhash is an object with a `type` member and a `validate` method. The\n`type` member is an object that matches what goes in the type list. The\n`validate` method is a function that gets called with `validate(data,\nkey, val)`. Validate methods should assign `data[key]` to the valid\nvalue of `val` if it can be handled properly, or return boolean\n`false` if it cannot.\n\nYou can also call `nopt.clean(data, types, typeDefs)` to clean up a\nconfig object and remove its invalid properties.\n\n## Error Handling\n\nBy default, nopt outputs a warning to standard error when invalid\noptions are found. You can change this behavior by assigning a method\nto `nopt.invalidHandler`. This method will be called with\nthe offending `nopt.invalidHandler(key, val, types)`.\n\nIf no `nopt.invalidHandler` is assigned, then it will console.error\nits whining. If it is assigned to boolean `false` then the warning is\nsuppressed.\n\n## Abbreviations\n\nYes, they are supported. If you define options like this:\n\n```javascript\n{ \"foolhardyelephants\" : Boolean\n, \"pileofmonkeys\" : Boolean }\n```\n\nThen this will work:\n\n```bash\nnode program.js --foolhar --pil\nnode program.js --no-f --pileofmon\n# etc.\n```\n\n## Shorthands\n\nShorthands are a hash of shorter option names to a snippet of args that\nthey expand to.\n\nIf multiple one-character shorthands are all combined, and the\ncombination does not unambiguously match any other option or shorthand,\nthen they will be broken up into their constituent parts. For example:\n\n```json\n{ \"s\" : [\"--loglevel\", \"silent\"]\n, \"g\" : \"--global\"\n, \"f\" : \"--force\"\n, \"p\" : \"--parseable\"\n, \"l\" : \"--long\"\n}\n```\n\n```bash\nnpm ls -sgflp\n# just like doing this:\nnpm ls --loglevel silent --global --force --long --parseable\n```\n\n## The Rest of the args\n\nThe config object returned by nopt is given a special member called\n`argv`, which is an object with the following fields:\n\n* `remain`: The remaining args after all the parsing has occurred.\n* `original`: The args as they originally appeared.\n* `cooked`: The args after flags and shorthands are expanded.\n\n## Slicing\n\nNode programs are called with more or less the exact argv as it appears\nin C land, after the v8 and node-specific options have been plucked off.\nAs such, `argv[0]` is always `node` and `argv[1]` is always the\nJavaScript program being run.\n\nThat's usually not very useful to you. So they're sliced off by\ndefault. If you want them, then you can pass in `0` as the last\nargument, or any other number that you'd like to slice off the start of\nthe list.\n",
+ "devDependencies": {
+ "tap": "~0.4.8"
+ },
+ "readme": "If you want to write an option parser, and have it be good, there are\ntwo ways to do it. The Right Way, and the Wrong Way.\n\nThe Wrong Way is to sit down and write an option parser. We've all done\nthat.\n\nThe Right Way is to write some complex configurable program with so many\noptions that you go half-insane just trying to manage them all, and put\nit off with duct-tape solutions until you see exactly to the core of the\nproblem, and finally snap and write an awesome option parser.\n\nIf you want to write an option parser, don't write an option parser.\nWrite a package manager, or a source control system, or a service\nrestarter, or an operating system. You probably won't end up with a\ngood one of those, but if you don't give up, and you are relentless and\ndiligent enough in your procrastination, you may just end up with a very\nnice option parser.\n\n## USAGE\n\n // my-program.js\n var nopt = require(\"nopt\")\n , Stream = require(\"stream\").Stream\n , path = require(\"path\")\n , knownOpts = { \"foo\" : [String, null]\n , \"bar\" : [Stream, Number]\n , \"baz\" : path\n , \"bloo\" : [ \"big\", \"medium\", \"small\" ]\n , \"flag\" : Boolean\n , \"pick\" : Boolean\n , \"many\" : [String, Array]\n }\n , shortHands = { \"foofoo\" : [\"--foo\", \"Mr. Foo\"]\n , \"b7\" : [\"--bar\", \"7\"]\n , \"m\" : [\"--bloo\", \"medium\"]\n , \"p\" : [\"--pick\"]\n , \"f\" : [\"--flag\"]\n }\n // everything is optional.\n // knownOpts and shorthands default to {}\n // arg list defaults to process.argv\n // slice defaults to 2\n , parsed = nopt(knownOpts, shortHands, process.argv, 2)\n console.log(parsed)\n\nThis would give you support for any of the following:\n\n```bash\n$ node my-program.js --foo \"blerp\" --no-flag\n{ \"foo\" : \"blerp\", \"flag\" : false }\n\n$ node my-program.js ---bar 7 --foo \"Mr. Hand\" --flag\n{ bar: 7, foo: \"Mr. Hand\", flag: true }\n\n$ node my-program.js --foo \"blerp\" -f -----p\n{ foo: \"blerp\", flag: true, pick: true }\n\n$ node my-program.js -fp --foofoo\n{ foo: \"Mr. Foo\", flag: true, pick: true }\n\n$ node my-program.js --foofoo -- -fp # -- stops the flag parsing.\n{ foo: \"Mr. Foo\", argv: { remain: [\"-fp\"] } }\n\n$ node my-program.js --blatzk -fp # unknown opts are ok.\n{ blatzk: true, flag: true, pick: true }\n\n$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value\n{ blatzk: 1000, flag: true, pick: true }\n\n$ node my-program.js --no-blatzk -fp # unless they start with \"no-\"\n{ blatzk: false, flag: true, pick: true }\n\n$ node my-program.js --baz b/a/z # known paths are resolved.\n{ baz: \"/Users/isaacs/b/a/z\" }\n\n# if Array is one of the types, then it can take many\n# values, and will always be an array. The other types provided\n# specify what types are allowed in the list.\n\n$ node my-program.js --many 1 --many null --many foo\n{ many: [\"1\", \"null\", \"foo\"] }\n\n$ node my-program.js --many foo\n{ many: [\"foo\"] }\n```\n\nRead the tests at the bottom of `lib/nopt.js` for more examples of\nwhat this puppy can do.\n\n## Types\n\nThe following types are supported, and defined on `nopt.typeDefs`\n\n* String: A normal string. No parsing is done.\n* path: A file system path. Gets resolved against cwd if not absolute.\n* url: A url. If it doesn't parse, it isn't accepted.\n* Number: Must be numeric.\n* Date: Must parse as a date. If it does, and `Date` is one of the options,\n then it will return a Date object, not a string.\n* Boolean: Must be either `true` or `false`. If an option is a boolean,\n then it does not need a value, and its presence will imply `true` as\n the value. To negate boolean flags, do `--no-whatever` or `--whatever\n false`\n* NaN: Means that the option is strictly not allowed. Any value will\n fail.\n* Stream: An object matching the \"Stream\" class in node. Valuable\n for use when validating programmatically. (npm uses this to let you\n supply any WriteStream on the `outfd` and `logfd` config options.)\n* Array: If `Array` is specified as one of the types, then the value\n will be parsed as a list of options. This means that multiple values\n can be specified, and that the value will always be an array.\n\nIf a type is an array of values not on this list, then those are\nconsidered valid values. For instance, in the example above, the\n`--bloo` option can only be one of `\"big\"`, `\"medium\"`, or `\"small\"`,\nand any other value will be rejected.\n\nWhen parsing unknown fields, `\"true\"`, `\"false\"`, and `\"null\"` will be\ninterpreted as their JavaScript equivalents, and numeric values will be\ninterpreted as a number.\n\nYou can also mix types and values, or multiple types, in a list. For\ninstance `{ blah: [Number, null] }` would allow a value to be set to\neither a Number or null. When types are ordered, this implies a\npreference, and the first type that can be used to properly interpret\nthe value will be used.\n\nTo define a new type, add it to `nopt.typeDefs`. Each item in that\nhash is an object with a `type` member and a `validate` method. The\n`type` member is an object that matches what goes in the type list. The\n`validate` method is a function that gets called with `validate(data,\nkey, val)`. Validate methods should assign `data[key]` to the valid\nvalue of `val` if it can be handled properly, or return boolean\n`false` if it cannot.\n\nYou can also call `nopt.clean(data, types, typeDefs)` to clean up a\nconfig object and remove its invalid properties.\n\n## Error Handling\n\nBy default, nopt outputs a warning to standard error when invalid\noptions are found. You can change this behavior by assigning a method\nto `nopt.invalidHandler`. This method will be called with\nthe offending `nopt.invalidHandler(key, val, types)`.\n\nIf no `nopt.invalidHandler` is assigned, then it will console.error\nits whining. If it is assigned to boolean `false` then the warning is\nsuppressed.\n\n## Abbreviations\n\nYes, they are supported. If you define options like this:\n\n```javascript\n{ \"foolhardyelephants\" : Boolean\n, \"pileofmonkeys\" : Boolean }\n```\n\nThen this will work:\n\n```bash\nnode program.js --foolhar --pil\nnode program.js --no-f --pileofmon\n# etc.\n```\n\n## Shorthands\n\nShorthands are a hash of shorter option names to a snippet of args that\nthey expand to.\n\nIf multiple one-character shorthands are all combined, and the\ncombination does not unambiguously match any other option or shorthand,\nthen they will be broken up into their constituent parts. For example:\n\n```json\n{ \"s\" : [\"--loglevel\", \"silent\"]\n, \"g\" : \"--global\"\n, \"f\" : \"--force\"\n, \"p\" : \"--parseable\"\n, \"l\" : \"--long\"\n}\n```\n\n```bash\nnpm ls -sgflp\n# just like doing this:\nnpm ls --loglevel silent --global --force --long --parseable\n```\n\n## The Rest of the args\n\nThe config object returned by nopt is given a special member called\n`argv`, which is an object with the following fields:\n\n* `remain`: The remaining args after all the parsing has occurred.\n* `original`: The args as they originally appeared.\n* `cooked`: The args after flags and shorthands are expanded.\n\n## Slicing\n\nNode programs are called with more or less the exact argv as it appears\nin C land, after the v8 and node-specific options have been plucked off.\nAs such, `argv[0]` is always `node` and `argv[1]` is always the\nJavaScript program being run.\n\nThat's usually not very useful to you. So they're sliced off by\ndefault. If you want them, then you can pass in `0` as the last\nargument, or any other number that you'd like to slice off the start of\nthe list.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/isaacs/nopt/issues"
},
"homepage": "https://github.com/isaacs/nopt",
- "_id": "nopt@2.1.2",
+ "_id": "nopt@2.2.0",
"_from": "nopt@~2"
}
View
235 node_modules/nodeunit/node_modules/tap/node_modules/nopt/test/basic.js
@@ -0,0 +1,235 @@
+var nopt = require("../")
+ , test = require('tap').test
+
+
+test("passing a string results in a string", function (t) {
+ var parsed = nopt({ key: String }, {}, ["--key", "myvalue"], 0)
+ t.same(parsed.key, "myvalue")
+ t.end()
+})
+
+// https://github.com/npm/nopt/issues/31
+test("Empty String results in empty string, not true", function (t) {
+ var parsed = nopt({ empty: String }, {}, ["--empty"], 0)
+ t.same(parsed.empty, "")
+ t.end()
+})
+
+test("other tests", function (t) {
+
+ var util = require("util")
+ , Stream = require("stream")
+ , path = require("path")
+ , url = require("url")
+
+ , shorthands =
+ { s : ["--loglevel", "silent"]
+ , d : ["--loglevel", "info"]
+ , dd : ["--loglevel", "verbose"]
+ , ddd : ["--loglevel", "silly"]
+ , noreg : ["--no-registry"]
+ , reg : ["--registry"]
+ , "no-reg" : ["--no-registry"]
+ , silent : ["--loglevel", "silent"]
+ , verbose : ["--loglevel", "verbose"]
+ , h : ["--usage"]
+ , H : ["--usage"]
+ , "?" : ["--usage"]
+ , help : ["--usage"]
+ , v : ["--version"]
+ , f : ["--force"]
+ , desc : ["--description"]
+ , "no-desc" : ["--no-description"]
+ , "local" : ["--no-global"]
+ , l : ["--long"]
+ , p : ["--parseable"]
+ , porcelain : ["--parseable"]
+ , g : ["--global"]
+ }
+
+ , types =
+ { aoa: Array
+ , nullstream: [null, Stream]
+ , date: Date
+ , str: String
+ , browser : String
+ , cache : path
+ , color : ["always", Boolean]
+ , depth : Number
+ , description : Boolean
+ , dev : Boolean
+ , editor : path
+ , force : Boolean
+ , global : Boolean
+ , globalconfig : path
+ , group : [String, Number]
+ , gzipbin : String
+ , logfd : [Number, Stream]
+ , loglevel : ["silent","win","error","warn","info","verbose","silly"]
+ , long : Boolean
+ , "node-version" : [false, String]
+ , npaturl : url
+ , npat : Boolean
+ , "onload-script" : [false, String]
+ , outfd : [Number, Stream]
+ , parseable : Boolean
+ , pre: Boolean
+ , prefix: path
+ , proxy : url
+ , "rebuild-bundle" : Boolean
+ , registry : url
+ , searchopts : String
+ , searchexclude: [null, String]
+ , shell : path
+ , t: [Array, String]
+ , tag : String
+ , tar : String
+ , tmp : path
+ , "unsafe-perm" : Boolean
+ , usage : Boolean
+ , user : String
+ , username : String
+ , userconfig : path
+ , version : Boolean
+ , viewer: path
+ , _exit : Boolean
+ , path: path
+ }
+
+ ; [["-v", {version:true}, []]
+ ,["---v", {version:true}, []]
+ ,["ls -s --no-reg connect -d",
+ {loglevel:"info",registry:null},["ls","connect"]]
+ ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]]
+ ,["ls --registry blargle", {}, ["ls"]]
+ ,["--no-registry", {registry:null}, []]
+ ,["--no-color true", {color:false}, []]
+ ,["--no-color false", {color:true}, []]
+ ,["--no-color", {color:false}, []]
+ ,["--color false", {color:false}, []]
+ ,["--color --logfd 7", {logfd:7,color:true}, []]
+ ,["--color=true", {color:true}, []]
+ ,["--logfd=10", {logfd:10}, []]
+ ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]]
+ ,["--tmp=tmp -tar=gtar",
+ {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]]
+ ,["--logfd x", {}, []]
+ ,["a -true -- -no-false", {true:true},["a","-no-false"]]
+ ,["a -no-false", {false:false},["a"]]
+ ,["a -no-no-true", {true:true}, ["a"]]
+ ,["a -no-no-no-false", {false:false}, ["a"]]
+ ,["---NO-no-No-no-no-no-nO-no-no"+
+ "-No-no-no-no-no-no-no-no-no"+
+ "-no-no-no-no-NO-NO-no-no-no-no-no-no"+
+ "-no-body-can-do-the-boogaloo-like-I-do"
+ ,{"body-can-do-the-boogaloo-like-I-do":false}, []]
+ ,["we are -no-strangers-to-love "+
+ "--you-know=the-rules --and=so-do-i "+
+ "---im-thinking-of=a-full-commitment "+
+ "--no-you-would-get-this-from-any-other-guy "+
+ "--no-gonna-give-you-up "+
+ "-no-gonna-let-you-down=true "+
+ "--no-no-gonna-run-around false "+
+ "--desert-you=false "+
+ "--make-you-cry false "+
+ "--no-tell-a-lie "+
+ "--no-no-and-hurt-you false"
+ ,{"strangers-to-love":false
+ ,"you-know":"the-rules"
+ ,"and":"so-do-i"
+ ,"you-would-get-this-from-any-other-guy":false
+ ,"gonna-give-you-up":false
+ ,"gonna-let-you-down":false
+ ,"gonna-run-around":false
+ ,"desert-you":false
+ ,"make-you-cry":false
+ ,"tell-a-lie":false
+ ,"and-hurt-you":false
+ },["we", "are"]]
+ ,["-t one -t two -t three"
+ ,{t: ["one", "two", "three"]}
+ ,[]]
+ ,["-t one -t null -t three four five null"
+ ,{t: ["one", "null", "three"]}
+ ,["four", "five", "null"]]
+ ,["-t foo"
+ ,{t:["foo"]}
+ ,[]]
+ ,["--no-t"
+ ,{t:["false"]}
+ ,[]]
+ ,["-no-no-t"
+ ,{t:["true"]}
+ ,[]]
+ ,["-aoa one -aoa null -aoa 100"
+ ,{aoa:["one", null, 100]}
+ ,[]]
+ ,["-str 100"
+ ,{str:"100"}
+ ,[]]
+ ,["--color always"
+ ,{color:"always"}
+ ,[]]
+ ,["--no-nullstream"
+ ,{nullstream:null}
+ ,[]]
+ ,["--nullstream false"
+ ,{nullstream:null}
+ ,[]]
+ ,["--notadate=2011-01-25"
+ ,{notadate: "2011-01-25"}
+ ,[]]
+ ,["--date 2011-01-25"
+ ,{date: new Date("2011-01-25")}
+ ,[]]
+ ,["-cl 1"
+ ,{config: true, length: 1}
+ ,[]
+ ,{config: Boolean, length: Number, clear: Boolean}
+ ,{c: "--config", l: "--length"}]
+ ,["--acount bla"
+ ,{"acount":true}
+ ,["bla"]
+ ,{account: Boolean, credentials: Boolean, options: String}
+ ,{a:"--account", c:"--credentials",o:"--options"}]
+ ,["--clear"
+ ,{clear:true}
+ ,[]
+ ,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean}
+ ,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}]
+ ,["--file -"
+ ,{"file":"-"}
+ ,[]
+ ,{file:String}
+ ,{}]
+ ,["--file -"
+ ,{"file":true}
+ ,["-"]
+ ,{file:Boolean}
+ ,{}]
+ ,["--path"
+ ,{"path":null}
+ ,[]]
+ ,["--path ."
+ ,{"path":process.cwd()}
+ ,[]]
+ ].forEach(function (test) {
+ var argv = test[0].split(/\s+/)
+ , opts = test[1]
+ , rem = test[2]
+ , actual = nopt(test[3] || types, test[4] || shorthands, argv, 0)
+ , parsed = actual.argv
+ delete actual.argv
+ for (var i in opts) {
+ var e = JSON.stringify(opts[i])
+ , a = JSON.stringify(actual[i] === undefined ? null : actual[i])
+ if (e && typeof e === "object") {
+ t.deepEqual(e, a)
+ } else {
+ t.equal(e, a)
+ }
+ }
+ t.deepEqual(rem, parsed.remain)
+ })
+ t.end()
+})
View
10 node_modules/nodeunit/package.json
@@ -1,6 +1,6 @@
{
"name": "nodeunit",
- "version": "0.8.4",
+ "version": "0.8.6",
"description": "Easy unit testing for node.js and the browser.",
"maintainers": [
{
@@ -91,15 +91,15 @@
"test": "node ./bin/nodeunit test"
},
"man": [
- "/home/scol/.npm/nodeunit/0.8.4/package/man1/nodeunit.1"
+ "/home/scol/.npm/nodeunit/0.8.6/package/man1/nodeunit.1"
],
"readme": "Nodeunit\n========\n\nSimple syntax, powerful tools. Nodeunit provides easy async unit testing for\nnode.js and the browser.\n\n* Simple to use\n* Just export the tests from a module\n* Works with node.js and in the browser.\n* Helps you avoid common pitfalls when testing asynchronous code\n* Easy to add test cases with setUp and tearDown functions if you wish\n* Flexible reporters for custom output, built-in support for HTML and jUnit XML\n* Allows the use of mocks and stubs\n\n__Contributors__\n\n* [alexgorbatchev](https://github.com/alexgorbatchev)\n* [alexkwolfe](https://github.com/alexkwolfe)\n* [azatoth](https://github.com/azatoth)\n* [kadirpekel](https://github.com/kadirpekel)\n* [lambdalisue](https://github.com/lambdalisue)\n* [luebken](https://github.com/luebken)\n* [orlandov](https://github.com/orlandov)\n* [Sannis](https://github.com/Sannis)\n* [sstephenson](https://github.com/sstephenson)\n* [thegreatape](https://github.com/thegreatape)\n* [mmalecki](https://github.com/mmalecki)\n* and thanks to [cjohansen](https://github.com/cjohansen) for input and advice\n on implementing setUp and tearDown functions. See\n [cjohansen's fork](https://github.com/cjohansen/nodeunit).\n\nAlso, check out gerad's [nodeunit-dsl](https://github.com/gerad/nodeunit-dsl)\nproject, which implements a 'pretty dsl on top of nodeunit'.\n\nMore contributor information can be found in the\n[CONTRIBUTORS.md](https://github.com/caolan/nodeunit/blob/master/CONTRIBUTORS.md)\nfile.\n\nUsage\n-----\n\nHere is an example unit test module:\n\n exports.testSomething = function(test){\n test.expect(1);\n test.ok(true, \"this assertion should pass\");\n test.done();\n };\n\n exports.testSomethingElse = function(test){\n test.ok(false, \"this assertion should fail\");\n test.done();\n };\n\nWhen run using the included test runner, this will output the following:\n\n<img src=\"https://github.com/caolan/nodeunit/raw/master/img/example_fail.png\" />\n\nInstallation\n------------\n\nThere are two options for installing nodeunit:\n\n1. Clone / download nodeunit from [github](https://github.com/caolan/nodeunit),\n then:\n\n make && sudo make install\n\n2. Install via npm:\n\n npm install nodeunit -g\n\nAPI Documentation\n-----------------\n\nNodeunit uses the functions available in the node.js\n[assert module](http://nodejs.org/docs/v0.4.2/api/assert.html):\n\n* __ok(value, [message])__ - Tests if value is a true value.\n* __equal(actual, expected, [message])__ - Tests shallow, coercive equality\n with the equal comparison operator ( == ).\n* __notEqual(actual, expected, [message])__ - Tests shallow, coercive\n non-equality with the not equal comparison operator ( != ).\n* __deepEqual(actual, expected, [message])__ - Tests for deep equality.\n* __notDeepEqual(actual, expected, [message])__ - Tests for any deep\n inequality.\n* __strictEqual(actual, expected, [message])__ - Tests strict equality, as\n determined by the strict equality operator ( === )\n* __notStrictEqual(actual, expected, [message])__ - Tests strict non-equality,\n as determined by the strict not equal operator ( !== )\n* __throws(block, [error], [message])__ - Expects block to throw an error.\n* __doesNotThrow(block, [error], [message])__ - Expects block not to throw an\n error.\n* __ifError(value)__ - Tests if value is not a false value, throws if it is a\n true value. Useful when testing the first argument, error in callbacks.\n\nNodeunit also provides the following functions within tests:\n\n* __expect(amount)__ - Specify how many assertions are expected to run within a\n test. Very useful for ensuring that all your callbacks and assertions are\n run.\n* __done()__ - Finish the current test function, and move on to the next. ALL\n tests should call this!\n\nNodeunit aims to be simple and easy to learn. This is achieved through using\nexisting structures (such as node.js modules) to maximum effect, and reducing\nthe API where possible, to make it easier to digest.\n\nTests are simply exported from a module, but they are still run in the order\nthey are defined.\n\n__Note:__ Users of old nodeunit versions may remember using ok, equals and same\nin the style of qunit, instead of the assert functions above. These functions\nstill exist for backwards compatibility, and are simply aliases to their assert\nmodule counterparts.\n\n\nAsynchronous Testing\n--------------------\n\nWhen testing asynchronous code, there are a number of sharp edges to watch out\nfor. Thankfully, nodeunit is designed to help you avoid as many of these\npitfalls as possible. For the most part, testing asynchronous code in nodeunit\n_just works_.\n\n\n### Tests run in series\n\nWhile running tests in parallel seems like a good idea for speeding up your\ntest suite, in practice I've found it means writing much more complicated\ntests. Because of node's module cache, running tests in parallel means mocking\nand stubbing is pretty much impossible. One of the nicest things about testing\nin javascript is the ease of doing stubs:\n\n var _readFile = fs.readFile;\n fs.readFile = function(path, callback){\n // its a stub!\n };\n // test function that uses fs.readFile\n\n // we're done\n fs.readFile = _readFile;\n\nYou cannot do this when running tests in parallel. In order to keep testing as\nsimple as possible, nodeunit avoids it. Thankfully, most unit-test suites run\nfast anyway.\n\n\n### Explicit ending of tests\n\nWhen testing async code its important that tests end at the correct point, not\njust after a given number of assertions. Otherwise your tests can run short,\nending before all assertions have completed. Its important to detect too\nmany assertions as well as too few. Combining explicit ending of tests with\nan expected number of assertions helps to avoid false test passes, so be sure\nto use the test.expect() method at the start of your test functions, and\ntest.done() when finished.\n\n\nGroups, setUp and tearDown\n--------------------------\n\nNodeunit allows the nesting of test functions:\n\n exports.test1 = function (test) {\n ...\n }\n\n exports.group = {\n test2: function (test) {\n ...\n },\n test3: function (test) {\n ...\n }\n }\n\nThis would be run as:\n\n test1\n group - test2\n group - test3\n\nUsing these groups, Nodeunit allows you to define a `setUp` function, which is\nrun before each test, and a `tearDown` function, which is run after each test\ncalls `test.done()`:\n\n module.exports = {\n setUp: function (callback) {\n this.foo = 'bar';\n callback();\n },\n tearDown: function (callback) {\n // clean up\n callback();\n },\n test1: function (test) {\n test.equals(this.foo, 'bar');\n test.done();\n }\n };\n\nIn this way, its possible to have multiple groups of tests in a module, each\ngroup with its own setUp and tearDown functions.\n\n\nRunning Tests\n-------------\n\nNodeunit comes with a basic command-line test runner, which can be installed\nusing 'sudo make install'. Example usage:\n\n nodeunit testmodule1.js testfolder [...]\n\nThe default test reporter uses color output, because I think that's more fun :) I\nintend to add a no-color option in future. To give you a feeling of the fun you'll\nbe having writing tests, lets fix the example at the start of the README:\n\n<img src=\"https://github.com/caolan/nodeunit/raw/master/img/example_pass.png\" />\n\nAhhh, Doesn't that feel better?\n\nWhen using the included test runner, it will exit using the failed number of\nassertions as the exit code. Exiting with 0 when all tests pass.\n\n\n### Command-line Options\n\n* __--reporter FILE__ - you can set the test reporter to a custom module or\non of the modules in nodeunit/lib/reporters, when omitted, the default test runner\nis used.\n* __--list-reporters__ - list available build-in reporters.\n* __--config FILE__ - load config options from a JSON file, allows\nthe customisation of color schemes for the default test reporter etc. See\nbin/nodeunit.json for current available options.\n* __--version__ or __-v__ - report nodeunit version\n* __--help__ - show nodeunit help\n\n\nRunning tests in the browser\n----------------------------\n\nNodeunit tests can also be run inside the browser. For example usage, see\nthe examples/browser folder. The basic syntax is as follows:\n\n__test.html__\n\n <html>\n <head>\n <title>Example Test Suite</title>\n <link rel=\"stylesheet\" href=\"nodeunit.css\" type=\"text/css\" />\n <script src=\"nodeunit.js\"></script>\n <script src=\"suite1.js\"></script>\n <script src=\"suite2.js\"></script>\n </head>\n <body>\n <h1 id=\"nodeunit-header\">Example Test Suite</h1>\n <script>\n nodeunit.run({\n 'Suite One': suite1,\n 'Suite Two': suite2\n });\n </script>\n </body>\n </html>\n\nHere, suite1 and suite2 are just object literals containing test functions or\ngroups, as would be returned if you did require('test-suite') in node.js:\n\n__suite1.js__\n\n this.suite1 = {\n 'example test': function (test) {\n test.ok(true, 'everything is ok');\n test.done();\n }\n };\n\nIf you wish to use a commonjs format for your test suites (using exports), it is\nup to you to define the commonjs tools for the browser. There are a number of\nalternatives and its important it fits with your existing code, which is\nwhy nodeunit does not currently provide this out of the box.\n\nIn the example above, the tests will run when the page is loaded.\n\nThe browser-version of nodeunit.js is created in dist/browser when you do, 'make\nbrowser'. You'll need [UglifyJS](https://github.com/mishoo/UglifyJS) installed in\norder for it to automatically create nodeunit.min.js.\n\n\nAdding nodeunit to Your Projects\n--------------------------------\n\nIf you don't want people to have to install the nodeunit command-line tool,\nyou'll want to create a script that runs the tests for your project with the\ncorrect require paths set up. Here's an example test script, that assumes you\nhave nodeunit in a suitably located node_modules directory.\n\n #!/usr/bin/env node\n var reporter = require('nodeunit').reporters.default;\n reporter.run(['test']);\n\nIf you're using git, you might find it useful to include nodeunit as a\nsubmodule. Using submodules makes it easy for developers to download nodeunit\nand run your test suite, without cluttering up your repository with\nthe source code. To add nodeunit as a git submodule do the following:\n\n git submodule add git://github.com/caolan/nodeunit.git node_modules/nodeunit\n\nThis will add nodeunit to the node_modules folder of your project. Now, when\ncloning the repository, nodeunit can be downloaded by doing the following:\n\n git submodule init\n git submodule update\n\nLet's update the test script above with a helpful hint on how to get nodeunit,\nif its missing:\n\n #!/usr/bin/env node\n try {\n var reporter = require('nodeunit').reporters.default;\n }\n catch(e) {\n console.log(\"Cannot find nodeunit module.\");\n console.log(\"You can download submodules for this project by doing:\");\n console.log(\"\");\n console.log(\" git submodule init\");\n console.log(\" git submodule update\");\n console.log(\"\");\n process.exit();\n }\n\n process.chdir(__dirname);\n reporter.run(['test']);\n\nNow if someone attempts to run your test suite without nodeunit installed they\nwill be prompted to download the submodules for your project.\n\n\nBuilt-in Test Reporters\n-----------------------\n\n* __default__ - The standard reporter seen in the nodeunit screenshots\n* __minimal__ - Pretty, minimal output, shows errors and progress only\n* __html__ - Outputs a HTML report to stdout\n* __junit__ - Creates jUnit compatible XML reports, which can be used with\n continuous integration tools such as [Hudson](http://hudson-ci.org/).\n* __machineout__ - Simple reporter for machine analysis. There is\n [nodeunit.vim](https://github.com/lambdalisue/nodeunit.vim) which is useful for TDD on VIM.\n\n\nWriting a Test Reporter\n---------------------\n\nNodeunit exports runTest(fn, options), runModule(mod, options) and\nrunFiles(paths, options). You'll most likely want to run test suites from\nfiles, which can be done using the latter function. The _options_ argument can\ncontain callbacks which run during testing. Nodeunit provides the following\ncallbacks:\n\n* __moduleStart(name)__ - called before a module is tested\n* __moduleDone(name, assertions)__ - called once all test functions within the\n module have completed (see assertions object reference below)\n ALL tests within the module\n* __testStart(name)__ - called before a test function is run\n* __testReady(test)__ - called before a test function is run with the test object that will be passed to the test function\n* __testDone(name, assertions)__ - called once a test function has completed\n (by calling test.done())\n* __log(assertion)__ - called whenever an assertion is made (see assertion\n object reference below)\n* __done(assertions)__ - called after all tests/modules are complete\n\nThe __assertion__ object:\n\n* __passed()__ - did the assertion pass?\n* __failed()__ - did the assertion fail?\n* __error__ - the AssertionError if the assertion failed\n* __method__ - the nodeunit assertion method used (ok, same, equals...)\n* __message__ - the message the assertion method was called with (optional)\n\nThe __assertionList__ object:\n\n* An array-like object with the following new attributes:\n * __failures()__ - the number of assertions which failed\n * __duration__ - the time taken for the test to complete in msecs\n\nFor a reference implementation of a test reporter, see lib/reporters/default.js in\nthe nodeunit project directory.\n\n\nSandbox utility\n---------------\n\nThis is a function which evaluates JavaScript files in a sandbox and returns the\ncontext. The sandbox function can be used for testing client-side code or private\nun-exported functions within a module.\n\n var sandbox = require('nodeunit').utils.sandbox;\n var example = sandbox('example.js');\n\n__sandbox(files, sandbox)__ - Evaluates JavaScript files in a sandbox, returning\nthe context. The first argument can either be a single filename or an array of\nfilenames. If multiple filenames are given their contents are concatenated before\nevaluation. The second argument is an optional context to use for the sandbox.\n\nNote: When working with the sandbox if your script depends on outside sources\n(i.e. using `require`) then you will want to pass that into the optional\ncontext when setting up the sandbox.\n\n var sandbox = require('nodeunit').utils.sandbox;\n // pass in some node globals\n var box_globals = {\n // Passing module.exports into the sandbox will give your code access to it.\n module: {exports: exports},\n // Passing require into the sandbox will give your code access to use it AND \n // will share the cache with modules already required from outside the sandbox.\n require: require,\n // Passing console into the sandbox will give your code access to it\n console: console\n };\n var example = sandbox('example.js', box_globals);\n\n\nRunning the nodeunit Tests\n--------------------------\n\nThe tests for nodeunit are written using nodeunit itself as the test framework.\nHowever, the module test-base.js first does some basic tests using the assert\nmodule to ensure that test functions are actually run, and a basic level of\nnodeunit functionality is available.\n\nTo run the nodeunit tests do:\n\n make test\n\n__Note:__ There was a bug in node v0.2.0 causing the tests to hang, upgrading\nto v0.2.1 fixes this.\n\n\n__machineout__ reporter\n----------------------------------------------\n\nThe default reporter is really readable for human but for machinally analysis. \nWhen you want to analyze the output of nodeunit, use __machineout__ reporter and you will get\n\n<img src=\"https://github.com/caolan/nodeunit/raw/master/img/example_machineout.png\" />\n\n\nnodeunit with vim\n----------------------------------\nThere is [nodeunit.vim](https://github.com/lambdalisue/nodeunit.vim) so you can use\nnodeunit with VIM.\n\nThat compiler uses __machineout__ reporter and it is useful to use\nwith [vim-makegreen](https://github.com/reinh/vim-makegreen).\n\n \n\nContributing\n------------\n\nContributions to the project are most welcome, so feel free to fork and improve.\nWhen submitting a pull request, please run `make lint` first to ensure\nwe're following a consistent coding style.\n",
"readmeFilename": "README.md",
"homepage": "https://github.com/caolan/nodeunit",
- "_id": "nodeunit@0.8.4",
+ "_id": "nodeunit@0.8.6",
"dist": {
- "shasum": "113377451980f91db1d0a50c4d9ad9038974e010"
+ "shasum": "4cc55e767ca6096a3193fd82314e42dedab3281d"
},
"_from": "nodeunit@",
- "_resolved": "https://registry.npmjs.org/nodeunit/-/nodeunit-0.8.4.tgz"
+ "_resolved": "https://registry.npmjs.org/nodeunit/-/nodeunit-0.8.6.tgz"
}
View
2  package.json
@@ -37,7 +37,7 @@
"grunt-nodemon": "~0.2.0",
"grunt-shell": "~0.6.4",
"nock": "~0.27.1",
- "nodeunit": "0.8.4",
+ "nodeunit": "0.8.6",
"super-request": "~0.0.4"
},
"scripts": {
Something went wrong with that request. Please try again.