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 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 utils = rootReq('grunt/utils');
|
||||||
var _ = rootReq('src/lib/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 = {
|
var config = {
|
||||||
unit: {
|
unit: {
|
||||||
@ -13,8 +14,7 @@ var config = {
|
|||||||
jenkins_unit: {
|
jenkins_unit: {
|
||||||
src: 'test/unit/index.js',
|
src: 'test/unit/index.js',
|
||||||
options: {
|
options: {
|
||||||
reporter: JENKINS_REPORTER,
|
reporter: JENKINS_REPORTER
|
||||||
output: 'test/junit-node-unit.xml'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -23,7 +23,6 @@ var config = {
|
|||||||
src: 'test/unit/coverage.js',
|
src: 'test/unit/coverage.js',
|
||||||
options: {
|
options: {
|
||||||
reporter: 'html-cov',
|
reporter: 'html-cov',
|
||||||
output: 'coverage.html',
|
|
||||||
instrument: false
|
instrument: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -47,8 +46,7 @@ utils.branches.forEach(function (branch) {
|
|||||||
config['jenkins_integration_' + branch] = {
|
config['jenkins_integration_' + branch] = {
|
||||||
src: 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js',
|
src: 'test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js',
|
||||||
options: {
|
options: {
|
||||||
reporter: JENKINS_REPORTER,
|
reporter: JENKINS_REPORTER
|
||||||
output: 'test/junit-node-integration.xml'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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) {
|
function JenkinsReporter(runner) {
|
||||||
Base.call(this, runner);
|
Base.call(this, runner);
|
||||||
|
|
||||||
@ -149,7 +161,8 @@ function JenkinsReporter(runner) {
|
|||||||
return s;
|
return s;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
console.error(xml);
|
|
||||||
|
fs.writeFileSync(output, xml, 'utf8');
|
||||||
|
|
||||||
console.log('\n' + [
|
console.log('\n' + [
|
||||||
'tests complete in ' + (Math.round(stats.duration / 10) / 100) + ' seconds',
|
'tests complete in ' + (Math.round(stats.duration / 10) / 100) + ' seconds',
|
||||||
|
|||||||
Reference in New Issue
Block a user