Skip to content

Commit

Permalink
Revert "[ftr/startServers] resolve relative config arguments at CLI (#…
Browse files Browse the repository at this point in the history
…141450)"

This reverts commit a5afcd7.
  • Loading branch information
spalger committed Sep 28, 2022
1 parent 4f9d277 commit 28b520e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@
* Side Public License, v 1.
*/

import Path from 'path';

import { getFlags, FlagsReader } from '@kbn/dev-cli-runner';
import { createAnyInstanceSerializer, createAbsolutePathSerializer } from '@kbn/jest-serializers';
import { REPO_ROOT } from '@kbn/utils';

import { EsVersion } from '../../functional_test_runner';
import { parseFlags, FLAG_OPTIONS } from './flags';

jest.mock('uuid', () => ({ v4: () => 'some-uuid' }));

const cwdMock = (process.cwd = jest.fn().mockReturnValue(REPO_ROOT));

expect.addSnapshotSerializer(
createAnyInstanceSerializer(EsVersion, (v: EsVersion) => `EsVersion ${v.toString()}`)
);
Expand All @@ -29,27 +23,10 @@ const defaults = getFlags(['--config=foo'], FLAG_OPTIONS);
const test = (opts: Record<string, string | string[] | boolean | undefined>) =>
parseFlags(new FlagsReader({ ...defaults, ...opts }));

beforeEach(() => {
cwdMock.mockReturnValue(REPO_ROOT);
});

it('parses a subset of the flags from runTests', () => {
expect(test({ config: 'foo' })).toMatchInlineSnapshot(`
Object {
"config": <absolute path>/foo,
"esFrom": undefined,
"esVersion": <EsVersion 9.9.9>,
"installDir": undefined,
"logsDir": undefined,
}
`);
});

it('respects the cwd of the script', () => {
cwdMock.mockReturnValue(Path.resolve(REPO_ROOT, 'x-pack'));
expect(test({ config: 'foo' })).toMatchInlineSnapshot(`
Object {
"config": <absolute path>/x-pack/foo,
"config": "foo",
"esFrom": undefined,
"esVersion": <EsVersion 9.9.9>,
"installDir": undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-test/src/functional_tests/start_servers/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const FLAG_OPTIONS: FlagOptions = {

export function parseFlags(flags: FlagsReader) {
const configs = [
...(flags.arrayOfPaths('config') ?? []),
...(flags.arrayOfPaths('journey') ?? []),
...(flags.arrayOfStrings('config') ?? []),
...(flags.arrayOfStrings('journey') ?? []),
];
if (configs.length !== 1) {
throw createFlagError(`expected exactly one --config or --journey flag`);
Expand Down

0 comments on commit 28b520e

Please sign in to comment.