1818 */
1919
2020import { resolve } from 'path' ;
21- import { run } from '@kbn/dev-utils' ;
21+ import { run , createFlagError , Flags } from '@kbn/dev-utils' ;
2222import { FunctionalTestRunner } from './functional_test_runner' ;
2323
24+ const makeAbsolutePath = ( v : string ) => resolve ( process . cwd ( ) , v ) ;
25+ const toArray = ( v : string | string [ ] ) => ( [ ] as string [ ] ) . concat ( v || [ ] ) ;
26+ const parseInstallDir = ( flags : Flags ) => {
27+ const flag = flags [ 'kibana-install-dir' ] ;
28+
29+ if ( typeof flag !== 'string' && flag !== undefined ) {
30+ throw createFlagError ( '--kibana-install-dir must be a string or not defined' ) ;
31+ }
32+
33+ return flag ? makeAbsolutePath ( flag ) : undefined ;
34+ } ;
35+
2436export function runFtrCli ( ) {
2537 run (
2638 async ( { flags, log } ) => {
27- const resolveConfigPath = ( v : string ) => resolve ( process . cwd ( ) , v ) ;
28- const toArray = ( v : string | string [ ] ) => ( [ ] as string [ ] ) . concat ( v || [ ] ) ;
29-
3039 const functionalTestRunner = new FunctionalTestRunner (
3140 log ,
32- resolveConfigPath ( flags . config as string ) ,
41+ makeAbsolutePath ( flags . config as string ) ,
3342 {
3443 mochaOpts : {
3544 bail : flags . bail ,
3645 grep : flags . grep || undefined ,
3746 invert : flags . invert ,
3847 } ,
48+ kbnTestServer : {
49+ installDir : parseInstallDir ( flags ) ,
50+ } ,
3951 suiteTags : {
4052 include : toArray ( flags [ 'include-tag' ] as string | string [ ] ) ,
4153 exclude : toArray ( flags [ 'exclude-tag' ] as string | string [ ] ) ,
@@ -84,7 +96,7 @@ export function runFtrCli() {
8496 } ,
8597 {
8698 flags : {
87- string : [ 'config' , 'grep' , 'exclude' , 'include-tag' , 'exclude-tag' ] ,
99+ string : [ 'config' , 'grep' , 'exclude' , 'include-tag' , 'exclude-tag' , 'kibana-install-dir' ] ,
88100 boolean : [ 'bail' , 'invert' , 'test-stats' , 'updateBaselines' ] ,
89101 default : {
90102 config : 'test/functional/config.js' ,
@@ -100,6 +112,7 @@ export function runFtrCli() {
100112 --exclude-tag=tag a tag to be excluded, pass multiple times for multiple tags
101113 --test-stats print the number of tests (included and excluded) to STDERR
102114 --updateBaselines replace baseline screenshots with whatever is generated from the test
115+ --kibana-install-dir directory where the Kibana install being tested resides
103116 ` ,
104117 } ,
105118 }
0 commit comments