Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into np-update-layer-d…
Browse files Browse the repository at this point in the history
…ependencies
  • Loading branch information
Aaron Caldwell committed Mar 17, 2020
2 parents 6654914 + 6a70d21 commit ccfc1ed
Show file tree
Hide file tree
Showing 318 changed files with 8,244 additions and 11,220 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
"@types/cheerio": "^0.22.10",
"@types/chromedriver": "^2.38.0",
"@types/classnames": "^2.2.9",
"@types/color": "^3.0.0",
"@types/d3": "^3.5.43",
"@types/dedent": "^0.7.0",
"@types/deep-freeze-strict": "^1.1.0",
Expand Down
18 changes: 15 additions & 3 deletions packages/kbn-test/src/functional_test_runner/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ export function runFtrCli() {
kbnTestServer: {
installDir: parseInstallDir(flags),
},
suiteFiles: {
include: toArray(flags.include as string | string[]).map(makeAbsolutePath),
exclude: toArray(flags.exclude as string | string[]).map(makeAbsolutePath),
},
suiteTags: {
include: toArray(flags['include-tag'] as string | string[]),
exclude: toArray(flags['exclude-tag'] as string | string[]),
},
updateBaselines: flags.updateBaselines,
excludeTestFiles: flags.exclude || undefined,
}
);

Expand Down Expand Up @@ -104,7 +107,15 @@ export function runFtrCli() {
},
{
flags: {
string: ['config', 'grep', 'exclude', 'include-tag', 'exclude-tag', 'kibana-install-dir'],
string: [
'config',
'grep',
'include',
'exclude',
'include-tag',
'exclude-tag',
'kibana-install-dir',
],
boolean: ['bail', 'invert', 'test-stats', 'updateBaselines', 'throttle', 'headless'],
default: {
config: 'test/functional/config.js',
Expand All @@ -115,7 +126,8 @@ export function runFtrCli() {
--bail stop tests after the first failure
--grep <pattern> pattern used to select which tests to run
--invert invert grep to exclude tests
--exclude=file path to a test file that should not be loaded
--include=file a test file to be included, pass multiple times for multiple files
--exclude=file a test file to be excluded, pass multiple times for multiple files
--include-tag=tag a tag to be included, pass multiple times for multiple tags
--exclude-tag=tag a tag to be excluded, pass multiple times for multiple tags
--test-stats print the number of tests (included and excluded) to STDERR
Expand Down
13 changes: 10 additions & 3 deletions packages/kbn-test/src/functional_test_runner/lib/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@ export const schema = Joi.object()
testFiles: Joi.array().items(Joi.string()),
testRunner: Joi.func(),

excludeTestFiles: Joi.array()
.items(Joi.string())
.default([]),
suiteFiles: Joi.object()
.keys({
include: Joi.array()
.items(Joi.string())
.default([]),
exclude: Joi.array()
.items(Joi.string())
.default([]),
})
.default(),

suiteTags: Joi.object()
.keys({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/

import { relative } from 'path';
import { REPO_ROOT } from '@kbn/dev-utils';
import { createAssignmentProxy } from './assignment_proxy';
import { wrapFunction } from './wrap_function';
import { wrapRunnableArgs } from './wrap_runnable_args';
Expand Down Expand Up @@ -65,6 +66,10 @@ export function decorateMochaUi(lifecycle, context) {
this._tags = [].concat(this._tags || [], tags);
};

const relativeFilePath = relative(REPO_ROOT, this.file);
this.tags(relativeFilePath);
this.suiteTag = relativeFilePath; // The tag that uniquely targets this suite/file

provider.call(this);

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,12 @@ import { decorateMochaUi } from './decorate_mocha_ui';
* @param {String} path
* @return {undefined} - mutates mocha, no return value
*/
export const loadTestFiles = ({
mocha,
log,
lifecycle,
providers,
paths,
excludePaths,
updateBaselines,
}) => {
const pendingExcludes = new Set(excludePaths.slice(0));

export const loadTestFiles = ({ mocha, log, lifecycle, providers, paths, updateBaselines }) => {
const innerLoadTestFile = path => {
if (typeof path !== 'string' || !isAbsolute(path)) {
throw new TypeError('loadTestFile() only accepts absolute paths');
}

if (pendingExcludes.has(path)) {
pendingExcludes.delete(path);
log.warning('Skipping test file %s', path);
return;
}

loadTracer(path, `testFile[${path}]`, () => {
log.verbose('Loading test file %s', path);

Expand Down Expand Up @@ -94,13 +78,4 @@ export const loadTestFiles = ({
};

paths.forEach(innerLoadTestFile);

if (pendingExcludes.size) {
throw new Error(
`After loading all test files some exclude paths were not consumed:${[
'',
...pendingExcludes,
].join('\n -')}`
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

import Mocha from 'mocha';
import { relative } from 'path';
import { REPO_ROOT } from '@kbn/dev-utils';

import { loadTestFiles } from './load_test_files';
import { filterSuitesByTags } from './filter_suites_by_tags';
Expand Down Expand Up @@ -50,10 +52,20 @@ export async function setupMocha(lifecycle, log, config, providers) {
lifecycle,
providers,
paths: config.get('testFiles'),
excludePaths: config.get('excludeTestFiles'),
updateBaselines: config.get('updateBaselines'),
});

// Each suite has a tag that is the path relative to the root of the repo
// So we just need to take input paths, make them relative to the root, and use them as tags
// Also, this is a separate filterSuitesByTags() call so that the test suites will be filtered first by
// files, then by tags. This way, you can target tags (like smoke) in a specific file.
filterSuitesByTags({
log,
mocha,
include: config.get('suiteFiles.include').map(file => relative(REPO_ROOT, file)),
exclude: config.get('suiteFiles.exclude').map(file => relative(REPO_ROOT, file)),
});

filterSuitesByTags({
log,
mocha,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions packages/kbn-test/src/functional_tests/cli/run_tests/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ const options = {
updateBaselines: {
desc: 'Replace baseline screenshots with whatever is generated from the test.',
},
include: {
arg: '<file>',
desc: 'Files that must included to be run, can be included multiple times.',
},
exclude: {
arg: '<file>',
desc: 'Files that must NOT be included to be run, can be included multiple times.',
},
'include-tag': {
arg: '<tag>',
desc: 'Tags that suites must include to be run, can be included multiple times.',
Expand Down Expand Up @@ -115,6 +123,13 @@ export function processOptions(userOptions, defaultConfigPaths) {
delete userOptions['kibana-install-dir'];
}

userOptions.suiteFiles = {
include: [].concat(userOptions.include || []),
exclude: [].concat(userOptions.exclude || []),
};
delete userOptions.include;
delete userOptions.exclude;

userOptions.suiteTags = {
include: [].concat(userOptions['include-tag'] || []),
exclude: [].concat(userOptions['exclude-tag'] || []),
Expand Down
6 changes: 5 additions & 1 deletion packages/kbn-test/src/functional_tests/lib/run_ftr.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { CliError } from './run_cli';

async function createFtr({
configPath,
options: { installDir, log, bail, grep, updateBaselines, suiteTags },
options: { installDir, log, bail, grep, updateBaselines, suiteFiles, suiteTags },
}) {
const config = await readConfigFile(log, configPath);

Expand All @@ -37,6 +37,10 @@ async function createFtr({
installDir,
},
updateBaselines,
suiteFiles: {
include: [...suiteFiles.include, ...config.get('suiteFiles.include')],
exclude: [...suiteFiles.exclude, ...config.get('suiteFiles.exclude')],
},
suiteTags: {
include: [...suiteTags.include, ...config.get('suiteTags.include')],
exclude: [...suiteTags.exclude, ...config.get('suiteTags.exclude')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export { npSetup, npStart } from 'ui/new_platform';

export { KbnUrl } from 'ui/url/kbn_url';
// @ts-ignore
export { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url/index';
export { KbnUrlProvider } from 'ui/url/index';
export { IInjector } from 'ui/chrome';
export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
KbnUrlProvider,
PrivateProvider,
PromiseServiceCreator,
RedirectWhenMissingProvider,
} from '../legacy_imports';
// @ts-ignore
import { initDashboardApp } from './legacy_app';
Expand Down Expand Up @@ -146,8 +145,7 @@ function createLocalIconModule() {
function createLocalKbnUrlModule() {
angular
.module('app/dashboard/KbnUrl', ['app/dashboard/Private', 'ngRoute'])
.service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider))
.service('redirectWhenMissing', (Private: IPrivate) => Private(RedirectWhenMissingProvider));
.service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider));
}

function createLocalConfigModule(core: AppMountContext['core']) {
Expand Down
Loading

0 comments on commit ccfc1ed

Please sign in to comment.