Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
*/

export * from './src/tooling_log';
export * from './src/serializers';
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

export { withProcRunner } from './proc_runner';
export { ToolingLog, ToolingLogTextWriter, pickLevelFromFlags } from './tooling_log';
export { createAbsolutePathSerializer } from './serializers';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.
*/

export function createAbsolutePathSerializer(
rootPath: string
): { print(...args: any[]): string; test(value: any): boolean };
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,9 @@
* under the License.
*/

import { createFunctionalTestRunner } from '../../../../../src/functional_test_runner';
import { CliError } from './run_cli';

export async function runFtr({
configPath,
options: { log, bail, grep, updateBaselines, suiteTags },
}) {
const ftr = createFunctionalTestRunner({
log,
configFile: configPath,
configOverrides: {
mochaOpts: {
bail: !!bail,
grep,
},
updateBaselines,
suiteTags,
},
});

const failureCount = await ftr.run();
if (failureCount > 0) {
throw new CliError(
`${failureCount} functional test ${failureCount === 1 ? 'failure' : 'failures'}`
);
}
export function createAbsolutePathSerializer(rootPath) {
return {
print: value => value.replace(rootPath, '<absolute path>').replace(/\\/g, '/'),
test: value => typeof value === 'string' && value.startsWith(rootPath),
};
}
20 changes: 20 additions & 0 deletions packages/kbn-dev-utils/src/serializers/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

export { createAbsolutePathSerializer } from './absolute_path_serializer';
20 changes: 20 additions & 0 deletions packages/kbn-dev-utils/src/serializers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

export { createAbsolutePathSerializer } from './absolute_path_serializer';
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Options:
--updateBaselines Replace baseline screenshots with whatever is generated from the test.
--include-tag <tag> Tags that suites must include to be run, can be included multiple times.
--exclude-tag <tag> Tags that suites must NOT include to be run, can be included multiple times.
--assert-none-excluded Exit with 1/0 based on if any test is excluded with the current set of tags.
--verbose Log everything.
--debug Run in debug mode.
--quiet Only log errors.
Expand All @@ -26,8 +27,9 @@ Options:

exports[`process options for run tests CLI accepts boolean value for updateBaselines 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand All @@ -41,8 +43,9 @@ Object {

exports[`process options for run tests CLI accepts debug option 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"debug": true,
Expand All @@ -56,9 +59,10 @@ Object {

exports[`process options for run tests CLI accepts empty config value if default passed 1`] = `
Object {
"assertNoneExcluded": false,
"config": "",
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand All @@ -74,8 +78,9 @@ Object {
"_": Object {
"server.foo": "bar",
},
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": Object {
Expand All @@ -90,8 +95,9 @@ Object {

exports[`process options for run tests CLI accepts quiet option 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand All @@ -105,8 +111,9 @@ Object {

exports[`process options for run tests CLI accepts silent option 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand All @@ -120,8 +127,9 @@ Object {

exports[`process options for run tests CLI accepts source value for esFrom 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"esFrom": "source",
Expand All @@ -135,8 +143,9 @@ Object {

exports[`process options for run tests CLI accepts string value for kibana-install-dir 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand All @@ -150,8 +159,9 @@ Object {

exports[`process options for run tests CLI accepts value for grep 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand All @@ -165,8 +175,9 @@ Object {

exports[`process options for run tests CLI accepts verbose option 1`] = `
Object {
"assertNoneExcluded": false,
"configs": Array [
"foo",
<absolute path>/foo,
],
"createLogger": [Function],
"extraKbnOpts": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Options:
--updateBaselines Replace baseline screenshots with whatever is generated from the test.
--include-tag <tag> Tags that suites must include to be run, can be included multiple times.
--exclude-tag <tag> Tags that suites must NOT include to be run, can be included multiple times.
--assert-none-excluded Exit with 1/0 based on if any test is excluded with the current set of tags.
--verbose Log everything.
--debug Run in debug mode.
--quiet Only log errors.
Expand Down
10 changes: 9 additions & 1 deletion packages/kbn-test/src/functional_tests/cli/run_tests/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import { resolve } from 'path';

import dedent from 'dedent';
import { ToolingLog, pickLevelFromFlags } from '@kbn/dev-utils';

Expand Down Expand Up @@ -52,6 +54,9 @@ const options = {
arg: '<tag>',
desc: 'Tags that suites must NOT include to be run, can be included multiple times.',
},
'assert-none-excluded': {
desc: 'Exit with 1/0 based on if any test is excluded with the current set of tags.',
},
verbose: { desc: 'Log everything.' },
debug: { desc: 'Run in debug mode.' },
quiet: { desc: 'Only log errors.' },
Expand Down Expand Up @@ -113,6 +118,9 @@ export function processOptions(userOptions, defaultConfigPaths) {
delete userOptions['include-tag'];
delete userOptions['exclude-tag'];

userOptions.assertNoneExcluded = !!userOptions['assert-none-excluded'];
delete userOptions['assert-none-excluded'];

function createLogger() {
return new ToolingLog({
level: pickLevelFromFlags(userOptions),
Expand All @@ -122,7 +130,7 @@ export function processOptions(userOptions, defaultConfigPaths) {

return {
...userOptions,
configs,
configs: configs.map(c => resolve(c)),
createLogger,
extraKbnOpts: userOptions._,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/

import { displayHelp, processOptions } from './args';
import { createAbsolutePathSerializer } from '@kbn/dev-utils';

expect.addSnapshotSerializer(createAbsolutePathSerializer(process.cwd()));

describe('display help for run tests CLI', () => {
it('displays as expected', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import { Writable } from 'stream';

import { runTestsCli } from './cli';
import { checkMockConsoleLogSnapshot } from '../../test_helpers';

Expand All @@ -36,7 +38,7 @@ describe('run tests CLI', () => {
const processMock = {
exit: exitMock,
argv: argvMock,
stdout: { on: jest.fn(), once: jest.fn(), emit: jest.fn() },
stdout: new Writable(),
cwd: jest.fn(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ Options:

exports[`process options for start servers CLI accepts debug option 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"debug": true,
"esFrom": "snapshot",
Expand All @@ -33,9 +31,7 @@ Object {

exports[`process options for start servers CLI accepts empty config value if default passed 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "snapshot",
"extraKbnOpts": undefined,
Expand All @@ -47,9 +43,7 @@ Object {
"_": Object {
"server.foo": "bar",
},
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "snapshot",
"extraKbnOpts": Object {
Expand All @@ -60,9 +54,7 @@ Object {

exports[`process options for start servers CLI accepts quiet option 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "snapshot",
"extraKbnOpts": undefined,
Expand All @@ -72,9 +64,7 @@ Object {

exports[`process options for start servers CLI accepts silent option 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "snapshot",
"extraKbnOpts": undefined,
Expand All @@ -84,9 +74,7 @@ Object {

exports[`process options for start servers CLI accepts source value for esFrom 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "source",
"extraKbnOpts": undefined,
Expand All @@ -95,9 +83,7 @@ Object {

exports[`process options for start servers CLI accepts string value for kibana-install-dir 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "snapshot",
"extraKbnOpts": undefined,
Expand All @@ -107,9 +93,7 @@ Object {

exports[`process options for start servers CLI accepts verbose option 1`] = `
Object {
"config": Array [
"foo",
],
"config": <absolute path>/foo,
"createLogger": [Function],
"esFrom": "snapshot",
"extraKbnOpts": undefined,
Expand Down
Loading