move all mocha driving into grunt

This commit is contained in:
Spencer Alger
2015-01-09 23:40:27 -07:00
parent c3831c2bf5
commit bbe49c3cc8
2 changed files with 21 additions and 26 deletions

View File

@ -3,11 +3,21 @@ var rootReq = function (p) { return require(require('path').resolve(root, p)); }
var utils = rootReq('grunt/utils');
var _ = rootReq('src/lib/utils');
var JENKINS_REPORTER = 'test/utils/jenkins-reporter.js';
var config = {
unit: {
src: 'test/unit/index.js'
},
jenkins_unit: {
src: 'test/unit/index.js',
options: {
reporter: JENKINS_REPORTER,
output: 'test/junit-node-unit.xml'
}
},
// run the unit tests, and update coverage.html
make_coverage_html: {
src: 'test/unit/coverage.js',
@ -33,6 +43,14 @@ utils.branches.forEach(function (branch) {
config['integration_' + branch] = {
src: 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js'
};
config['jenkins_integration_' + branch] = {
src: 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js',
options: {
reporter: JENKINS_REPORTER,
output: 'test/junit-node-integration.xml'
}
};
});
module.exports = config;

View File

@ -17,15 +17,12 @@ var through2 = require('through2');
var map = require('through2-map');
var split = require('split');
var join = require('path').join;
var fs = require('fs');
var child_process = require('child_process');
var chalk = require('chalk');
var format = require('util').format;
var ROOT = join(__dirname, '..');
var GRUNT = join(ROOT, './node_modules/.bin/grunt');
var MOCHA = join(ROOT, './node_modules/.bin/mocha');
var MOCHA_REPORTER = 'test/utils/jenkins-reporter.js';
var ENV = _.clone(process.env);
var JENKINS = !!ENV.JENKINS_HOME;
@ -89,9 +86,7 @@ task(
return grunt('jshint', 'mochacov:unit');
}
var report = join(ROOT, 'test/junit-node-unit.xml');
var tests = join(ROOT, 'test/unit/index.js');
return mocha(report, tests, '--reporter', join(ROOT, MOCHA_REPORTER));
return grunt('mochacov:jenkins_unit');
}
);
@ -103,19 +98,8 @@ task(
return node('scripts/generate', '--no-api', '--branch', branch)
.then(function () {
if (JENKINS) return;
return grunt('esvm:ci_env', 'mochacov:integration_' + branch, 'esvm_shutdown:ci_env');
})
.then(function () {
if (!JENKINS) return;
var branchSuffix = '_' + branch.replace(/\./g, '_');
var tests = 'test/integration/yaml_suite/index' + branchSuffix + '.js';
var esPort = ENV.es_port || 9200;
var report = 'test/junit-node-integration.xml';
return mocha(report, tests, '--host', 'localhost', '--port', esPort, '--reporter', MOCHA_REPORTER);
var target = (JENKINS ? 'jenkins_' : '') + 'integration_' + branch;
return grunt('esvm:ci_env', 'mochacov:' + target, 'esvm_shutdown:ci_env');
});
}
);
@ -330,11 +314,4 @@ function node(/*args... */) {
function grunt(/* args... */) {
return spawn(GRUNT, _.toArray(arguments));
}
function mocha(report/*, args... */) {
return spawn(MOCHA, _.rest(arguments, 1), function (cp) {
cp.stderr.unpipe();
cp.stderr.pipe(fs.createWriteStream(report));
});
}