From 63c999789dc08b9a3b56b22f25f478f13050da29 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 27 Apr 2018 11:39:20 -0700 Subject: [PATCH] tests: fix cli handling empty runnerResult during gatherMode (#5052) --- lighthouse-cli/run.js | 2 +- lighthouse-cli/test/cli/run-test.js | 8 ++++++++ lighthouse-core/runner.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lighthouse-cli/run.js b/lighthouse-cli/run.js index 32e47e83ca..4e3c76335c 100644 --- a/lighthouse-cli/run.js +++ b/lighthouse-cli/run.js @@ -100,12 +100,12 @@ function handleError(err) { * @return {Promise} */ function saveResults(runnerResult, flags) { - const {lhr, artifacts} = runnerResult; const cwd = process.cwd(); let promise = Promise.resolve(); const shouldSaveResults = flags.auditMode || (flags.gatherMode === flags.auditMode); if (!shouldSaveResults) return promise; + const {lhr, artifacts} = runnerResult; // Use the output path as the prefix for all generated files. // If no output path is set, generate a file prefix using the URL and date. diff --git a/lighthouse-cli/test/cli/run-test.js b/lighthouse-cli/test/cli/run-test.js index 48fef6e304..31df112636 100644 --- a/lighthouse-cli/test/cli/run-test.js +++ b/lighthouse-cli/test/cli/run-test.js @@ -53,6 +53,14 @@ describe('flag coercing', () => { }); }); + +describe('saveResults', () => { + it('will quit early if we\'re in gather mode', async () => { + const result = await run.saveResults(undefined, {gatherMode: true}); + assert.equal(result, undefined); + }); +}); + describe('Parsing --chrome-flags', () => { it('returns boolean flags that are true as a bare flag', () => { assert.deepStrictEqual(parseChromeFlags('--debug'), ['--debug']); diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index c617654d8f..0d17f99ac4 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -179,7 +179,7 @@ class Runner { artifacts = Object.assign(Runner.instantiateComputedArtifacts(), artifacts); if (artifacts.settings) { - const overrides = {gatherMode: undefined, auditMode: undefined}; + const overrides = {gatherMode: undefined, auditMode: undefined, output: undefined}; const normalizedGatherSettings = Object.assign({}, artifacts.settings, overrides); const normalizedAuditSettings = Object.assign({}, settings, overrides);