Skip to content

Commit

Permalink
Make tests less verbose, lose junit reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
gotwarlost committed Feb 10, 2013
1 parent b80c89d commit e82ee68
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
23 changes: 17 additions & 6 deletions test/cli-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var path = require('path'),
EXCLUDES = [ '**/node_modules/**', '**/test/**', '**/yui-load-hook.js'],
COVER_VAR = '$$selfcover$$',
seq = 0,
verbose = false,
OPTS = {
};

Expand Down Expand Up @@ -54,6 +55,9 @@ var path = require('path'),
*
*/

function setVerbose(flag) {
verbose = flag;
}
function setOpts(userOpts) {
Object.keys(userOpts).forEach(function (k) { OPTS[k] = userOpts[k]; });
}
Expand All @@ -75,10 +79,12 @@ function runCommand(command, args, envVars, callback) {
return item.match(pat);
});
if (filtered.length === 0) {
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
console.log('Could not find: ' + pat + ' in:');
console.log(array.join('\n'));
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
if (verbose) {
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
console.log('Could not find: ' + pat + ' in:');
console.log(array.join('\n'));
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
}
}
return filtered.length > 0;
};
Expand Down Expand Up @@ -116,11 +122,15 @@ function runCommand(command, args, envVars, callback) {
handle.stderr.setEncoding('utf8');
handle.stdout.on('data', function (data) {
out += data;
process.stdout.write(data);
if (verbose) {
process.stdout.write(data);
}
});
handle.stderr.on('data', function (data) {
err += data;
process.stderr.write(data);
if (verbose) {
process.stderr.write(data);
}
});
handle.on('exit', function (exitCode) {
setTimeout(function () {
Expand Down Expand Up @@ -184,6 +194,7 @@ function customHook(lazyHook, callback) {
}

module.exports = {
setVerbose: setVerbose,
runCommand: runCommand,
resetOpts: resetOpts,
setOpts: setOpts
Expand Down
19 changes: 19 additions & 0 deletions test/run-again.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node

var nodeunit = require('nodeunit'),
mkdirp = require('mkdirp'),
loader = require('./loader'),
common = require('./common');

function runTests() {
var outputDir = common.getBuildDir();

mkdirp.sync(outputDir);
loader.runTests(process.argv[2], nodeunit.reporters['default'], undefined, function (err) {
if (err) { throw err; }
});
}

runTests();


30 changes: 0 additions & 30 deletions test/run-junit.js

This file was deleted.

8 changes: 5 additions & 3 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ var nodeunit = require('nodeunit'),
loader = require('./loader'),
child_process = require('child_process'),
rimraf = require('rimraf'),
common = require('./common');
common = require('./common'),
cliHelper = require('./cli-helper');

function runTests(pat, forceCover) {
var defaultReporter = nodeunit.reporters['default'],
selfCover = forceCover || process.env.npm_config_coverage, //set by npm test --coverage
args,
proc;

cliHelper.setVerbose(process.env.VERBOSE);
loader.runTests(pat, defaultReporter, undefined, function (err) {
var coverageDir = common.getCoverageDir();
//if any test failed then we cannot obviously run self-coverage
Expand All @@ -55,7 +57,7 @@ function runTests(pat, forceCover) {
common.setSelfCover(true);
console.log('Running self-coverage....');
// run the equivalent of
// $ istanbul cover run-junit.js -- <pat>
// $ istanbul cover run-again.js -- <pat>
args = [
path.resolve(__dirname, '..', 'lib', 'cli.js'),
'cover',
Expand All @@ -70,7 +72,7 @@ function runTests(pat, forceCover) {
'**/test/**',
'--x',
'**/yui-load-hook.js',
path.resolve(__dirname, 'run-junit.js'),
path.resolve(__dirname, 'run-again.js'),
'--',
pat || ''
];
Expand Down

0 comments on commit e82ee68

Please sign in to comment.