Merge pull request elastic/kibana-plugin-helpers#22 from elastic/enh/test-all-task

Add test task

Original commit: elastic/kibana-plugin-helpers@63e507b3ff
This commit is contained in:
Joe Fleming 2016-12-15 10:33:19 -07:00 committed by GitHub
commit be64fe21a4
7 changed files with 27 additions and 5 deletions

View file

@ -24,8 +24,15 @@ program
.on('--help', docs('build'))
.action(run('build'));
program
.command('test')
.description('Run the server and browser tests')
.on('--help', docs('test/all'))
.action(run('test/all'));
program
.command('test:browser')
.option('--dev', 'Enable dev mode, keeps the test server running')
.description('Run the browser tests in a real web browser')
.on('--help', docs('test/browser'))
.action(run('test/browser'));

View file

@ -6,6 +6,6 @@ module.exports = function run(name) {
// call the action function with the plugin, then all
// renaining arguments from commander
var plugin = pluginConfig();
action.apply(null, [plugin].concat([].slice.apply(arguments)));
action.apply(null, [plugin, run].concat([].slice.apply(arguments)));
};
};

View file

@ -1,8 +1,13 @@
module.exports = function (plugin, command) {
module.exports = function (plugin, run, command) {
var execFileSync = require('child_process').execFileSync;
var cmd = (process.platform === 'win32') ? 'bin\\kibana.bat' : 'bin/kibana';
var args = ['--dev', '--plugin-path', plugin.root, ...command.unkownOptions];
var args = ['--dev', '--plugin-path', plugin.root];
if (command.unkownOptions) {
args = args.concat(command.unkownOptions);
}
execFileSync(cmd, args, {
cwd: plugin.kibanaRoot,
stdio: ['ignore', 1, 2]

View file

@ -0,0 +1,3 @@
Runs both the server and browser tests, in that order.
This is just a simple caller to both `test/server` and `test/browser`

View file

@ -0,0 +1 @@
module.exports = require('./test_all_action');

View file

@ -0,0 +1,4 @@
module.exports = function testAllAction(plugin, run) {
run('test/server')();
run('test/browser')();
};

View file

@ -1,5 +1,6 @@
module.exports = function (plugin) {
module.exports = function testBrowserAction(plugin, run, command) {
var execFileSync = require('child_process').execFileSync;
command = command || {};
var kbnServerArgs = [
'--kbnServer.testsBundle.pluginId=' + plugin.id,
@ -7,7 +8,8 @@ module.exports = function (plugin) {
];
var cmd = 'npm';
var args = ['run', 'test:dev', '--'].concat(kbnServerArgs);
var task = (command.dev) ? 'test:dev' : 'test:browser';
var args = ['run', task, '--'].concat(kbnServerArgs);
execFileSync(cmd, args, {
cwd: plugin.kibanaRoot,
stdio: ['ignore', 1, 2]