Permalink
Browse files

added jscoverage support

  • Loading branch information...
1 parent b0003fe commit f3cf374350939bad1bc801539a8082e8994a1dd4 @twobit committed Nov 2, 2012
Showing with 54 additions and 43 deletions.
  1. +3 −1 .gitignore
  2. +7 −1 Makefile
  3. +31 −31 build/gear.js
  4. +1 −1 build/gear.min.js
  5. +10 −3 index.js
  6. +2 −6 test/tasks.js
View
@@ -1,2 +1,4 @@
node_modules
-testing
+testing
+coverage.html
+lib-cov
View
@@ -6,4 +6,10 @@ bootstrap:
test:
npm test
-.PHONY: test
+test-cov: lib-cov
+ @GEAR_COV=1 mocha --require should --reporter html-cov > coverage.html
+
+lib-cov:
+ @jscoverage lib lib-cov
+
+.PHONY: test
View
@@ -2131,7 +2131,7 @@ define('async', ['require', 'exports', 'module'], function(require, exports, mod
else {
completed += 1;
if (completed === arr.length) {
- callback();
+ callback(null);
}
}
});
@@ -2153,7 +2153,7 @@ define('async', ['require', 'exports', 'module'], function(require, exports, mod
else {
completed += 1;
if (completed === arr.length) {
- callback();
+ callback(null);
}
else {
iterate();
@@ -2163,41 +2163,41 @@ define('async', ['require', 'exports', 'module'], function(require, exports, mod
};
iterate();
};
-
+
async.forEachLimit = function (arr, limit, iterator, callback) {
callback = callback || function () {};
if (!arr.length || limit <= 0) {
- return callback();
+ return callback();
}
var completed = 0;
var started = 0;
var running = 0;
-
+
(function replenish () {
- if (completed === arr.length) {
- return callback();
- }
-
- while (running < limit && started < arr.length) {
- iterator(arr[started], function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- running -= 1;
- if (completed === arr.length) {
- callback();
- }
- else {
- replenish();
- }
- }
- });
- started += 1;
- running += 1;
- }
+ if (completed === arr.length) {
+ return callback();
+ }
+
+ while (running < limit && started < arr.length) {
+ started += 1;
+ running += 1;
+ iterator(arr[started - 1], function (err) {
+ if (err) {
+ callback(err);
+ callback = function () {};
+ }
+ else {
+ completed += 1;
+ running -= 1;
+ if (completed === arr.length) {
+ callback();
+ }
+ else {
+ replenish();
+ }
+ }
+ });
+ }
})();
};
@@ -2440,7 +2440,7 @@ define('async', ['require', 'exports', 'module'], function(require, exports, mod
var ready = function () {
return _reduce(requires, function (a, x) {
return (a && results.hasOwnProperty(x));
- }, true);
+ }, true) && !results.hasOwnProperty(k);
};
if (ready()) {
task[task.length - 1](taskCallback, results);
@@ -2726,7 +2726,7 @@ define('async', ['require', 'exports', 'module'], function(require, exports, mod
async.unmemoize = function (fn) {
return function () {
return (fn.unmemoized || fn).apply(null, arguments);
- }
+ };
};
}());
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -3,6 +3,13 @@
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
-exports.Registry = require('./lib/registry').Registry;
-exports.Queue = require('./lib/queue').Queue;
-exports.Blob = require('./lib/blob').Blob;
+
+if (process.env.GEAR_COV) {
+ exports.Registry = require('./lib-cov/registry').Registry;
+ exports.Queue = require('./lib-cov/queue').Queue;
+ exports.Blob = require('./lib-cov/blob').Blob;
+} else {
+ exports.Registry = require('./lib/registry').Registry;
+ exports.Queue = require('./lib/queue').Queue;
+ exports.Blob = require('./lib/blob').Blob;
+}
View
@@ -13,10 +13,8 @@ describe('Queue()', function() {
new gear.Queue().tasks({
read_files: {task: ['read', fixtures.files]},
concat_files: {requires: 'read_files', task: 'concat'},
- inspect_results: {requires: 'concat_files', task: 'inspect'},
read_files2: {task: ['read', fixtures.parallel_files]},
- inspect_results2: {requires: 'read_files2', task: 'inspect'},
- inspect_1_and_2: {requires: ['inspect_results2', 'inspect_results'], task: ['log', 'Done']}
+ done: {requires: ['read_files2', 'concat_files']}
}).run();
});
});
@@ -39,10 +37,8 @@ describe('tasks()', function() {
tasks.call(queue, {
read_files: {task: ['read', fixtures.files]},
concat_files: {requires: 'read_files', task: 'concat'},
- inspect_results: {requires: 'concat_files', task: 'inspect'},
read_files2: {task: ['read', fixtures.parallel_files]},
- inspect_results2: {requires: 'read_files2', task: 'inspect'},
- inspect_1_and_2: {requires: ['inspect_results', 'inspect_results2'], task: ['log', 'Done']}
+ inspect_1_and_2: {requires: ['concat_files', 'read_files2']}
}, [], function(err, results) {
done(err);
});

0 comments on commit f3cf374

Please sign in to comment.