Permalink
Browse files

Merge pull request #25 from arikon/istanbul

Autotests on mocha, code coverage on istanbul, CI on Travis
  • Loading branch information...
2 parents 26d03e6 + 142336e commit e3291d0cace9023822f5e69bf67a7928635d6517 @arikon arikon committed Oct 29, 2012
Showing with 550 additions and 279 deletions.
  1. +3 −1 .gitignore
  2. +10 −0 .travis.yml
  3. +16 −3 GNUmakefile
  4. +1 −0 README.md
  5. +1 −0 index.js
  6. +1 −1 lib/arg.js
  7. +13 −2 lib/cmd.js
  8. +0 −3 lib/coa.js
  9. +1 −1 lib/color.js
  10. +1 −1 lib/completion.js
  11. +7 −0 lib/index.js
  12. +1 −1 lib/opt.js
  13. +1 −1 lib/shell.js
  14. +10 −3 package.json
  15. +9 −1 src/cmd.coffee
  16. +0 −1 src/coa.coffee
  17. +3 −0 src/index.coffee
  18. +422 −0 test/coa.js
  19. +1 −0 test/common.js
  20. +4 −0 test/mocha.opts
  21. +43 −42 test/shell-test.js
  22. +0 −14 tests/a.js
  23. +0 −34 tests/api-args.js
  24. +0 −27 tests/api-cmd.js
  25. +1 −1 tests/api-h.js
  26. +0 −21 tests/args.js
  27. +0 −14 tests/cmd.js
  28. +0 −25 tests/def.js
  29. +1 −1 tests/h.js
  30. +0 −21 tests/l.js
  31. +0 −13 tests/rarg.js
  32. +0 −10 tests/req.js
  33. +0 −23 tests/v.js
  34. +0 −14 tests/val.js
View
@@ -1,3 +1,5 @@
.idea
*.iml
-node_modules
+node_modules/
+lib-cov/
+html-report/
View
@@ -0,0 +1,10 @@
+language: node_js
+
+node_js:
+ - 0.6
+ - 0.8
+ - 0.9
+
+matrix:
+ allow_failures:
+ - node_js: 0.9
View
@@ -1,15 +1,28 @@
+BIN = ./node_modules/.bin
+
.PHONY: all
all: lib
lib: $(foreach s,$(wildcard src/*.coffee),$(patsubst src/%.coffee,lib/%.js,$s))
+lib-cov: lib
+ $(BIN)/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib
+
lib/%.js: src/%.coffee
- ./node_modules/.bin/coffee -cb -o $(@D) $<
+ $(BIN)/coffee -cb -o $(@D) $<
.PHONY: test
test: lib
- ./node_modules/.bin/vows --spec
+ $(BIN)/mocha
+
+.PHONY: coverage
+coverage: lib-cov
+ COVER=1 $(BIN)/mocha --reporter mocha-istanbul
.PHONY: watch
watch:
- coffee --watch --bare --output lib src/*.coffee
+ $(BIN)/coffee --watch --bare --output lib src/*.coffee
+
+.PHONY: clean
+clean:
+ -rm -rf lib-cov
View
@@ -1,4 +1,5 @@
# Command-Option-Argument
+[![build status](https://secure.travis-ci.org/veged/coa.png)](http://travis-ci.org/veged/coa)
## What is it?
View
@@ -0,0 +1 @@
+module.exports = require(process.env.COVER? './lib-cov' : './lib');
View
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
var Arg, Cmd, Color, Opt;
Color = require('./color').Color;
View
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
var Cmd, Color, PATH, Q, UTIL,
__slice = [].slice;
@@ -456,11 +456,22 @@ exports.Cmd = Cmd = (function() {
}
};
};
- Q.when(this._do(this._parseArr(argv)), cb(0), cb(1)).end();
+ Q.when(this["do"](argv), cb(0), cb(1)).end();
return this;
};
/**
+ Convenient function to run command from tests.
+ @param {Array} argv
+ @returns {Q.Promise}
+ */
+
+
+ Cmd.prototype["do"] = function(argv) {
+ return this._do(this._parseArr(argv || []));
+ };
+
+ /**
Invoke specified (or current) command using provided
options and arguments.
@param {String|Array} cmds subcommand to invoke (optional)
View
@@ -1,3 +0,0 @@
-// Generated by CoffeeScript 1.3.3
-
-exports.Cmd = require('./cmd').Cmd;
View
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
var colors;
colors = {
View
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
/**
Most of the code adopted from the npm package shell completion code.
See https://github.com/isaacs/npm/blob/master/lib/completion.js
View
@@ -0,0 +1,7 @@
+// Generated by CoffeeScript 1.4.0
+
+exports.Cmd = require('./cmd').Cmd;
+
+exports.shell = require('./shell');
+
+exports.require = require;
View
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
var Cmd, Color, Opt, Q, fs;
fs = require('fs');
View
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
exports.unescape = function(w) {
w = w.charAt(0) === '"' ? w.replace(/^"|([^\\])"$/g, '$1') : w.replace(/\\ /g, ' ');
View
@@ -18,13 +18,20 @@
"directories": {
"lib": "./lib"
},
- "main": "./lib/coa.js",
"dependencies": {
"q": "~0.8.8"
},
"devDependencies": {
- "coffee-script": "~1.3.3",
- "vows": "~0.6.4"
+ "coffee-script": "~1.4.0",
+ "istanbul": "~0.1.11",
+ "mocha-as-promised": "*",
+ "mocha-istanbul": "*",
+ "mocha": "~1.6.0",
+ "chai": "~1.3.0"
+ },
+ "scripts": {
+ "test": "make test",
+ "coverage": "make coverage"
},
"engines": {
"node": ">= 0.6.0"
View
@@ -342,10 +342,18 @@ exports.Cmd = class Cmd
@_exit res.stack ? res.toString(), res.exitCode ? code
else
@_exit()
- Q.when(@_do(@_parseArr argv), cb(0), cb(1)).end()
+ Q.when(@do(argv), cb(0), cb(1)).end()
@
###*
+ Convenient function to run command from tests.
+ @param {Array} argv
+ @returns {Q.Promise}
+ ###
+ do: (argv) ->
+ @_do(@_parseArr argv || [])
+
+ ###*
Invoke specified (or current) command using provided
options and arguments.
@param {String|Array} cmds subcommand to invoke (optional)
View
@@ -1 +0,0 @@
-exports.Cmd = require('./cmd').Cmd
View
@@ -0,0 +1,3 @@
+exports.Cmd = require('./cmd').Cmd
+exports.shell = require('./shell')
+exports.require = require;
Oops, something went wrong. Retry.

0 comments on commit e3291d0

Please sign in to comment.