Permalink
Browse files

Make tests less verbose, lose junit reporter

  • Loading branch information...
1 parent b80c89d commit e82ee68b0bbaf7bc96f3060e9d34dc3ca7e9ba1a @gotwarlost committed Feb 10, 2013
Showing with 41 additions and 39 deletions.
  1. +17 −6 test/cli-helper.js
  2. +19 −0 test/run-again.js
  3. +0 −30 test/run-junit.js
  4. +5 −3 test/run.js
View
@@ -11,6 +11,7 @@ var path = require('path'),
EXCLUDES = [ '**/node_modules/**', '**/test/**', '**/yui-load-hook.js'],
COVER_VAR = '$$selfcover$$',
seq = 0,
+ verbose = false,
OPTS = {
};
@@ -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]; });
}
@@ -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;
};
@@ -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 () {
@@ -184,6 +194,7 @@ function customHook(lazyHook, callback) {
}
module.exports = {
+ setVerbose: setVerbose,
runCommand: runCommand,
resetOpts: resetOpts,
setOpts: setOpts
View
@@ -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();
+
+
View
@@ -1,30 +0,0 @@
-#!/usr/bin/env node
-
-var nodeunit = require('nodeunit'),
- mkdirp = require('mkdirp'),
- loader = require('./loader'),
- common = require('./common');
-
-function runTests() {
- var junitReporter = nodeunit.reporters.junit,
- outputDir = common.getBuildDir();
-
- mkdirp.sync(outputDir);
- loader.runTests(process.argv[2], junitReporter, {
- output: outputDir,
- error_prefix: "\u001B[31m",
- error_suffix: "\u001B[39m",
- ok_prefix: "\u001B[32m",
- ok_suffix: "\u001B[39m",
- bold_prefix: "\u001B[1m",
- bold_suffix: "\u001B[22m",
- assertion_prefix: "\u001B[35m",
- assertion_suffix: "\u001B[39m"
- }, function (err) {
- if (err) { throw err; }
- });
-}
-
-runTests();
-
-
View
@@ -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
@@ -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',
@@ -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 || ''
];

0 comments on commit e82ee68

Please sign in to comment.