2018-05-29 05:06:30 +02:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2016-09-02 00:02:43 +02:00
|
|
|
import _, { keys } from 'lodash';
|
2016-11-16 01:11:03 +01:00
|
|
|
|
2017-06-06 19:11:59 +02:00
|
|
|
import { run } from '../utilities/visual_regression';
|
2016-06-10 06:36:09 +02:00
|
|
|
|
2019-12-13 23:44:04 +01:00
|
|
|
module.exports = function(grunt) {
|
2016-06-10 06:36:09 +02:00
|
|
|
grunt.registerTask(
|
2016-06-22 01:59:43 +02:00
|
|
|
'test:visualRegression:buildGallery',
|
2016-06-10 06:36:09 +02:00
|
|
|
'Compare screenshots and generate diff images.',
|
2019-12-13 23:44:04 +01:00
|
|
|
function() {
|
2016-06-10 06:36:09 +02:00
|
|
|
const done = this.async();
|
2017-06-06 19:11:59 +02:00
|
|
|
run(done);
|
2016-06-10 06:36:09 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-02-18 23:21:36 +01:00
|
|
|
grunt.registerTask('test:karma', [
|
2019-12-13 23:44:04 +01:00
|
|
|
'checkPlugins',
|
|
|
|
'run:browserSCSS',
|
2020-02-18 23:21:36 +01:00
|
|
|
'run:karmaTestServer',
|
2019-12-13 23:44:04 +01:00
|
|
|
'karma:unit',
|
|
|
|
]);
|
2016-11-16 01:11:03 +01:00
|
|
|
|
2020-02-18 23:21:36 +01:00
|
|
|
grunt.registerTask('test:karma-ci', () => {
|
2016-09-02 00:02:43 +02:00
|
|
|
const ciShardTasks = keys(grunt.config.get('karma'))
|
|
|
|
.filter(key => key.startsWith('ciShard-'))
|
|
|
|
.map(key => `karma:${key}`);
|
|
|
|
|
|
|
|
grunt.log.ok(`Running UI tests in ${ciShardTasks.length} shards`);
|
2018-10-04 18:10:20 +02:00
|
|
|
grunt.task.run(['run:browserSCSS']);
|
2020-02-18 23:21:36 +01:00
|
|
|
grunt.task.run(['run:karmaTestServer', ...ciShardTasks]);
|
2016-09-02 00:02:43 +02:00
|
|
|
});
|
2016-11-16 01:11:03 +01:00
|
|
|
|
2018-07-28 16:41:57 +02:00
|
|
|
grunt.registerTask('test:coverage', ['run:testCoverageServer', 'karma:coverage']);
|
2015-08-18 23:51:31 +02:00
|
|
|
|
|
|
|
grunt.registerTask('test:quick', [
|
2018-07-23 21:48:27 +02:00
|
|
|
'checkPlugins',
|
2019-08-15 19:21:42 +02:00
|
|
|
'run:mocha',
|
2018-07-23 21:48:27 +02:00
|
|
|
'run:functionalTests',
|
2017-04-06 03:24:01 +02:00
|
|
|
'test:jest',
|
2018-02-19 17:02:01 +01:00
|
|
|
'test:jest_integration',
|
2018-03-09 14:28:47 +01:00
|
|
|
'test:projects',
|
2020-02-18 23:21:36 +01:00
|
|
|
'test:karma',
|
2018-07-28 16:41:57 +02:00
|
|
|
'run:apiIntegrationTests',
|
2015-08-18 23:51:31 +02:00
|
|
|
]);
|
|
|
|
|
2020-02-18 23:21:36 +01:00
|
|
|
grunt.registerTask('test:karmaDebug', ['checkPlugins', 'run:karmaDebugServer', 'karma:dev']);
|
2019-08-24 16:48:08 +02:00
|
|
|
grunt.registerTask('test:mochaCoverage', ['run:mochaCoverage']);
|
2015-08-18 23:51:31 +02:00
|
|
|
|
2016-06-10 06:36:09 +02:00
|
|
|
grunt.registerTask('test', subTask => {
|
2015-08-18 23:51:31 +02:00
|
|
|
if (subTask) grunt.fail.fatal(`invalid task "test:${subTask}"`);
|
|
|
|
|
2018-07-28 16:41:57 +02:00
|
|
|
grunt.task.run(
|
|
|
|
_.compact([
|
|
|
|
!grunt.option('quick') && 'run:eslint',
|
2019-01-03 17:01:43 +01:00
|
|
|
!grunt.option('quick') && 'run:sasslint',
|
2019-03-08 22:51:55 +01:00
|
|
|
!grunt.option('quick') && 'run:checkTsProjects',
|
2019-04-03 12:26:00 +02:00
|
|
|
!grunt.option('quick') && 'run:checkCoreApiChanges',
|
2018-08-10 02:19:24 +02:00
|
|
|
!grunt.option('quick') && 'run:typeCheck',
|
2018-08-29 10:55:34 +02:00
|
|
|
!grunt.option('quick') && 'run:i18nCheck',
|
2018-07-28 16:41:57 +02:00
|
|
|
'run:checkFileCasing',
|
2019-12-04 00:09:47 +01:00
|
|
|
'run:licenses',
|
2018-07-28 16:41:57 +02:00
|
|
|
'test:quick',
|
|
|
|
])
|
|
|
|
);
|
2014-09-20 00:41:25 +02:00
|
|
|
});
|
|
|
|
|
2015-08-18 23:51:31 +02:00
|
|
|
grunt.registerTask('quick-test', ['test:quick']); // historical alias
|
2018-03-09 14:28:47 +01:00
|
|
|
|
2019-12-13 23:44:04 +01:00
|
|
|
grunt.registerTask('test:projects', function() {
|
2018-03-09 14:28:47 +01:00
|
|
|
const done = this.async();
|
|
|
|
runProjectsTests().then(done, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
function runProjectsTests() {
|
|
|
|
const serverCmd = {
|
|
|
|
cmd: 'yarn',
|
2019-03-08 00:04:29 +01:00
|
|
|
args: ['kbn', 'run', 'test', '--exclude', 'kibana', '--oss', '--skip-kibana-plugins'],
|
2018-07-28 16:41:57 +02:00
|
|
|
opts: { stdio: 'inherit' },
|
2018-03-09 14:28:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
grunt.util.spawn(serverCmd, (error, result, code) => {
|
|
|
|
if (error || code !== 0) {
|
|
|
|
const error = new Error(`projects tests exited with code ${code}`);
|
|
|
|
grunt.fail.fatal(error);
|
|
|
|
reject(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
grunt.log.writeln(result);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2014-02-24 23:14:31 +01:00
|
|
|
};
|