detect arguments to pick output location in jenkins-reporter
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
var root = require('find-root')(__dirname);
|
||||
var rootReq = function (p) { return require(require('path').resolve(root, p)); };
|
||||
var rel = require('path').resolve.bind(null, root);
|
||||
var rootReq = function (p) { return require(rel(p)); };
|
||||
var utils = rootReq('grunt/utils');
|
||||
var _ = rootReq('src/lib/utils');
|
||||
|
||||
var JENKINS_REPORTER = 'test/utils/jenkins-reporter.js';
|
||||
var JENKINS_REPORTER = rel('test/utils/jenkins-reporter.js');
|
||||
|
||||
var config = {
|
||||
unit: {
|
||||
@ -13,8 +14,7 @@ var config = {
|
||||
jenkins_unit: {
|
||||
src: 'test/unit/index.js',
|
||||
options: {
|
||||
reporter: JENKINS_REPORTER,
|
||||
output: 'test/junit-node-unit.xml'
|
||||
reporter: JENKINS_REPORTER
|
||||
}
|
||||
},
|
||||
|
||||
@ -23,7 +23,6 @@ var config = {
|
||||
src: 'test/unit/coverage.js',
|
||||
options: {
|
||||
reporter: 'html-cov',
|
||||
output: 'coverage.html',
|
||||
instrument: false
|
||||
}
|
||||
},
|
||||
@ -47,8 +46,7 @@ utils.branches.forEach(function (branch) {
|
||||
config['jenkins_integration_' + branch] = {
|
||||
src: 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js',
|
||||
options: {
|
||||
reporter: JENKINS_REPORTER,
|
||||
output: 'test/junit-node-integration.xml'
|
||||
reporter: JENKINS_REPORTER
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@ -24,6 +24,18 @@ var log = (function () {
|
||||
};
|
||||
})();
|
||||
|
||||
var integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; });
|
||||
var unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; });
|
||||
var output;
|
||||
|
||||
if (unit) {
|
||||
output = path.join(__dirname, '../junit-node-unit.xml');
|
||||
} else if (integration) {
|
||||
output = path.join(__dirname, '../junit-node-integration.xml');
|
||||
} else {
|
||||
throw new Error('unable to detect unit or integration tests');
|
||||
}
|
||||
|
||||
function JenkinsReporter(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
@ -149,7 +161,8 @@ function JenkinsReporter(runner) {
|
||||
return s;
|
||||
})
|
||||
});
|
||||
console.error(xml);
|
||||
|
||||
fs.writeFileSync(output, xml, 'utf8');
|
||||
|
||||
console.log('\n' + [
|
||||
'tests complete in ' + (Math.round(stats.duration / 10) / 100) + ' seconds',
|
||||
|
||||
Reference in New Issue
Block a user