[6.6] Fix plugin-helpers test:server task (#31034) (#31079)

Backports the following commits to 6.6:
 - Fix plugin-helpers test:server task  (#31034)
This commit is contained in:
Spencer 2019-02-14 13:48:52 -08:00 committed by GitHub
parent 5fd9aa225d
commit 6dcb8043e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 19 deletions

View file

@ -14,6 +14,7 @@
"del": "^2.2.2",
"execa": "^1.0.0",
"gulp-rename": "1.2.2",
"globby": "^8.0.1",
"gulp-zip": "^4.1.0",
"inquirer": "^1.2.2",
"minimatch": "^3.0.4",

View file

@ -17,32 +17,30 @@
* under the License.
*/
const resolve = require('path').resolve;
const delimiter = require('path').delimiter;
const execFileSync = require('child_process').execFileSync;
const winCmd = require('../../../lib/win_cmd');
const globby = require('globby');
module.exports = function (plugin, run, options) {
options = options || {};
const kibanaBins = resolve(plugin.kibanaRoot, 'node_modules/.bin');
const mochaSetupJs = resolve(plugin.kibanaRoot, 'test/mocha_setup.js');
let testPaths = plugin.serverTestPatterns;
let testPatterns = plugin.serverTestPatterns;
// allow server test files to be overridden
if (options.files && options.files.length) {
testPaths = options.files;
testPatterns = options.files;
}
const fullCmd = resolve(plugin.kibanaRoot, 'node_modules', '.bin', 'mocha');
const cmd = winCmd(fullCmd);
const args = ['--require', mochaSetupJs].concat(testPaths);
const path = `${kibanaBins}${delimiter}${process.env.PATH}`;
execFileSync(cmd, args, {
cwd: plugin.root,
stdio: ['ignore', 1, 2],
env: Object.assign({}, process.env, {
PATH: path
})
});
execFileSync(
process.execPath,
[
'scripts/mocha',
...globby.sync(testPatterns, {
cwd: plugin.root,
absolute: true,
}),
],
{
cwd: plugin.kibanaRoot,
stdio: ['ignore', 1, 2],
}
);
};