Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add include library and coverage report feature
  • Loading branch information
hpychan committed Jul 28, 2011
1 parent 76565ef commit 27e27d1
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions bin/vows
Expand Up @@ -3,6 +3,7 @@
var path = require('path'), var path = require('path'),
fs = require('fs'), fs = require('fs'),
util = require('util'), util = require('util'),
childProcess = require('child_process'),
events = require('events'); events = require('events');


// //
Expand Down Expand Up @@ -102,6 +103,15 @@ while (arg = argv.shift()) {
options[arg] = true; options[arg] = true;
} else { } else {
switch (arg) { switch (arg) {
case 'i':
case 'I':
case 'include':
if (arg = argv.shift()) {
require.paths.unshift(arg);
} else {
throw new Error('--include requires a path');
}
break;
case 'json': case 'json':
_reporter = require('../lib/vows/reporters/json'); _reporter = require('../lib/vows/reporters/json');
break; break;
Expand Down Expand Up @@ -208,28 +218,42 @@ if (! options.watch) {
files = args.map(function (a) { files = args.map(function (a) {
return path.join(process.cwd(), a.replace(fileExt, '')); return path.join(process.cwd(), a.replace(fileExt, ''));
}); });


runSuites(importSuites(files), function (results) { var allTests = function() {
var status = results.errored ? 2 : (results.broken ? 1 : 0);

runSuites(importSuites(files), function (results) {
!options.verbose && _reporter.print('\n'); var status = results.errored ? 2 : (results.broken ? 1 : 0);
msg('runner', 'finish');
_reporter.report(['finish', results], { !options.verbose && _reporter.print('\n');
write: function (str) { msg('runner', 'finish');
util.print(str.replace(/^\n\n/, '\n')); _reporter.report(['finish', results], {
} write: function (str) {
}); util.print(str.replace(/^\n\n/, '\n'));
if (options.coverage === true && _$jscoverage !== undefined) { }
_coverage.report(_$jscoverage); });
} if (options.coverage === true && _$jscoverage !== undefined) {
if (process.stdout.write('')) { // Check if stdout is drained _coverage.report(_$jscoverage);
process.exit(status); }
} else { if (process.stdout.write('')) { // Check if stdout is drained
process.stdout.on('drain', function () { process.exit(status);
process.exit(status); } else {
}); process.stdout.on('drain', function () {
} process.exit(status);
}); });
}
});
};


if (options.coverage === true ) {
childProcess.exec('rm -fr lib-cov && jscoverage lib lib-cov', function(err){
if (err) throw err;
require.paths.unshift('lib-cov');
allTests();
})
} else {
allTests();
}
} else { } else {
// //
// Watch mode // Watch mode
Expand Down

3 comments on commit 27e27d1

@ciaranj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, this completely obviates my testrunner.js that dif this in lieu of it!

@hpychan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a good thing??

@ciaranj
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

Please sign in to comment.