Skip to content

Commit

Permalink
feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Mar 19, 2018
1 parent 99f66c0 commit 0589b8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function getFlags(manualArgv) {
'disable-cpu-throttling': 'Disable CPU throttling',
'disable-network-throttling': 'Disable network throttling',
'gather-mode':
'Collect artifacts from a connected browser and save to disk. If audit-mode is not also enabled, the run will quit early.',
'audit-mode': 'Process saved artifacts from disk',
'Collect artifacts from a connected browser and save to disk. (Artifacts folder path may optionally be provided). If audit-mode is not also enabled, the run will quit early.',
'audit-mode': 'Process saved artifacts from disk. (Artifacts folder path may be provided, otherwise defaults to ./latest-run/)',
'save-assets': 'Save the trace contents & screenshots to disk',
'list-all-audits': 'Prints a list of all available audits and exits',
'list-trace-categories': 'Prints a list of all required trace categories and exits',
Expand Down
7 changes: 3 additions & 4 deletions lighthouse-core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class Runner {
// Gather phase
// Either load saved artifacts off disk, from config, or get from the browser
if (opts.flags.auditMode && !opts.flags.gatherMode) {
run = run.then(_ => Runner._loadArtifactsFromDisk(Runner._getArtifactsPath(opts.flags)));
const path = Runner._getArtifactsPath(opts.flags);
run = run.then(_ => Runner._loadArtifactsFromDisk(path));
} else if (opts.config.artifacts) {
run = run.then(_ => opts.config.artifacts);
} else {
Expand Down Expand Up @@ -415,7 +416,7 @@ class Runner {

/**
* Get path to use for -G and -A modes. Defaults to $CWD/latest-run
* @param {*} flags
* @param {Flags} flags
* @return {string}
*/
static _getArtifactsPath(flags) {
Expand All @@ -427,5 +428,3 @@ class Runner {
}

module.exports = Runner;


10 changes: 7 additions & 3 deletions lighthouse-core/test/runner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const driverMock = require('./gather/fake-driver');
const Config = require('../config/config');
const Audit = require('../audits/audit');
const assetSaver = require('../lib/asset-saver');
const fs = require('fs');
const assert = require('assert');
const path = require('path');
const sinon = require('sinon');
Expand All @@ -37,7 +38,7 @@ describe('Runner', () => {
resetSpies();
});

describe('Gather Mode & Audit Mode', () => {
describe.only('Gather Mode & Audit Mode', () => {
const url = 'https://example.com';
const generateConfig = _ => new Config({
passes: [{
Expand All @@ -46,10 +47,10 @@ describe('Runner', () => {
audits: ['content-width'],
});
const artifactsPath = '.tmp/test_artifacts';
const resolvedPath = Runner._getArtifactsPath({auditMode: artifactsPath});

after(() => {
const path = Runner._getArtifactsPath({auditMode: artifactsPath});
rimraf.sync(path);
rimraf.sync(resolvedPath);
});

it('-G gathers, quits, and doesn\'t run audits', () => {
Expand All @@ -64,6 +65,9 @@ describe('Runner', () => {

assert.equal(gatherRunnerRunSpy.called, true, 'GatherRunner.run was not called');
assert.equal(runAuditSpy.called, false, '_runAudit was called');

assert.ok(fs.existsSync(resolvedPath));
assert.ok(fs.existsSync(`${resolvedPath}/artifacts.json`));
});
});

Expand Down
4 changes: 2 additions & 2 deletions typings/externs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ declare namespace LH {
enableErrorReporting: boolean;
listAllAudits: boolean;
listTraceCategories: boolean;
auditMode: boolean;
gatherMode: boolean;
auditMode: boolean|string;
gatherMode: boolean|string;
configPath?: string;
perf: boolean;
mixedContent: boolean;
Expand Down

0 comments on commit 0589b8f

Please sign in to comment.