From c18364ff62c8fa3cd78c872b90a49be8a8e9b713 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 7 Nov 2019 20:27:53 -0600 Subject: [PATCH] tests(cli): merge conflicts resolved with start server command --- packages/cli/test/cli.test.js | 6 +----- packages/utils/src/child-process-helper.js | 5 ++++- packages/utils/test/child-process-helper.test.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/cli/test/cli.test.js b/packages/cli/test/cli.test.js index 34e3d5a5c..8318e4853 100644 --- a/packages/cli/test/cli.test.js +++ b/packages/cli/test/cli.test.js @@ -166,7 +166,7 @@ describe('Lighthouse CI CLI', () => { it('should collect results with a server command', () => { const startCommand = `yarn start server -p=14927 --storage.sqlDatabasePath=${tmpSqlFilePath}`; - let {stdout = '', stderr = '', status = -1} = spawnSync(CLI_PATH, [ + const {stdout, stderr, status} = runCLI([ 'collect', `-n=1`, `--rc-file=${rcFile}`, @@ -174,10 +174,6 @@ describe('Lighthouse CI CLI', () => { `--url=http://localhost:14927/app/`, ]); - stdout = stdout.toString(); - stderr = stderr.toString(); - status = status || 0; - const stdoutClean = stdout .replace(/:\d{4,6}/g, ':XXXX') .replace(/sqlDatabasePath=.*?"/, 'sqlDatabasePath="'); diff --git a/packages/utils/src/child-process-helper.js b/packages/utils/src/child-process-helper.js index a3ccf08f7..86a9f8a94 100644 --- a/packages/utils/src/child-process-helper.js +++ b/packages/utils/src/child-process-helper.js @@ -72,7 +72,10 @@ function getListOfRunningCommands() { .spawnSync('ps', ['aux']) .stdout.toString() .split('\n') - .map(line => line.split(/\d+:\d+\.\d+/)[1]) + .map(line => { + const matches = line.split(/\s+\d+:\d+(\.\d+)?/g); + return matches && matches[matches.length - 1]; + }) .filter(Boolean) .map(command => command.trim()); } diff --git a/packages/utils/test/child-process-helper.test.js b/packages/utils/test/child-process-helper.test.js index c270e5a79..aaa3ccfd0 100644 --- a/packages/utils/test/child-process-helper.test.js +++ b/packages/utils/test/child-process-helper.test.js @@ -22,7 +22,7 @@ async function tryUntilPasses(fn, timeout = 5000) { await fn(); return; } catch (err) { - lastError = error; + lastError = err; await wait(); } }