Skip to content

Commit

Permalink
move driver/ to gather/
Browse files Browse the repository at this point in the history
rename gather/index.js to gather/gather-runner.js
rename DriverBase class to Driver
  • Loading branch information
brendankenny authored and paulirish committed Jul 28, 2016
1 parent 1c62db3 commit 35d0360
Show file tree
Hide file tree
Showing 50 changed files with 57 additions and 56 deletions.
9 changes: 5 additions & 4 deletions lighthouse-core/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

const defaultConfig = require('./default.json');
const recordsFromLogs = require('../lib/network-recorder').recordsFromLogs;
const CriticalRequestChainsGatherer = require('../driver/gatherers/critical-request-chains');
const SpeedlineGatherer = require('../driver/gatherers/speedline');
const Driver = require('../driver');
const CriticalRequestChainsGatherer = require('../gather/gatherers/critical-request-chains');
const SpeedlineGatherer = require('../gather/gatherers/speedline');

const GatherRunner = require('../gather/gather-runner');
const log = require('../lib/log');

// cleanTrace is run to remove duplicate TracingStartedInPage events,
Expand Down Expand Up @@ -115,7 +116,7 @@ function filterPasses(passes, audits) {

freshPass.gatherers = freshPass.gatherers.filter(gatherer => {
try {
const GathererClass = Driver.getGathererClass(gatherer);
const GathererClass = GatherRunner.getGathererClass(gatherer);
return requiredGatherers.has(GathererClass.name);
} catch (requireError) {
throw new Error(`Unable to locate gatherer: ${gatherer}`);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ const NetworkRecorder = require('../../lib/network-recorder');
const emulation = require('../../lib/emulation');
const Element = require('../../lib/element');

class DriverBase {
class Driver {

constructor() {
this._url = null;
this.PAUSE_AFTER_LOAD = 500;
this._chrome = null;
this._traceEvents = [];
this._traceCategories = DriverBase.traceCategories;
this._traceCategories = Driver.traceCategories;
}

get url() {
Expand Down Expand Up @@ -363,5 +363,5 @@ class DriverBase {
}
}

module.exports = DriverBase;
module.exports = Driver;

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const log = require('../lib/log.js');
const Audit = require('../audits/audit');

class Driver {
class GatherRunner {
static loadPage(driver, options) {
// Since a Page.reload command does not let a service worker take over, we
// navigate away and then come back to reload. We do not `waitForLoad` on
Expand Down Expand Up @@ -238,7 +238,7 @@ class Driver {
return gatherer;
}

const GathererClass = Driver.getGathererClass(gatherer);
const GathererClass = GatherRunner.getGathererClass(gatherer);
return new GathererClass();
});

Expand All @@ -247,4 +247,4 @@ class Driver {
}
}

module.exports = Driver;
module.exports = GatherRunner;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lighthouse-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const semver = require('semver');
const Runner = require('./runner');
const log = require('./lib/log.js');
const ChromeProtocol = require('./driver/drivers/cri.js');
const ChromeProtocol = require('./gather/drivers/cri.js');
const Config = require('./config');

/**
Expand Down Expand Up @@ -72,4 +72,4 @@ module.exports = function(url, flags, configJSON) {
};

module.exports.getAuditList = Runner.getAuditList;
module.exports.traceCategories = require('./driver/drivers/driver').traceCategories;
module.exports.traceCategories = require('./gather/drivers/driver').traceCategories;
6 changes: 3 additions & 3 deletions lighthouse-core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
'use strict';

const Driver = require('./driver');
const GatherRunner = require('./gather/gather-runner');
const Aggregator = require('./aggregator');
const assetSaver = require('./lib/asset-saver');
const log = require('./lib/log');
Expand All @@ -36,12 +36,12 @@ class Runner {
// Make a run, which can be .then()'d with whatever needs to run (based on the config).
let run = Promise.resolve();

// If there are passes run the Driver and gather the artifacts. If not, we will need
// If there are passes run the GatherRunner and gather the artifacts. If not, we will need
// to check that there are artifacts specified in the config, and throw if not.
if (validPassesAndAudits || validArtifactsAndAudits) {
if (validPassesAndAudits) {
// Finally set up the driver to gather.
run = run.then(_ => Driver.run(config.passes, Object.assign({}, opts, {driver})));
run = run.then(_ => GatherRunner.run(config.passes, Object.assign({}, opts, {driver})));
} else if (validArtifactsAndAudits) {
run = run.then(_ => config.artifacts);
}
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/audits/time-to-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'use strict';

const Audit = require('../../audits/time-to-interactive.js');
const SpeedlineGather = require('../../driver/gatherers/speedline');
const SpeedlineGather = require('../../gather/gatherers/speedline');
const assert = require('assert');

const traceContents = require('../fixtures/traces/progressive-app.json');
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

/* eslint-env mocha */

const Gather = require('../../driver/gatherers/gather');
const Driver = require('../../driver');
const Gather = require('../../gather/gatherers/gather');
const GatherRunner = require('../../gather/gather-runner');
const Audit = require('../../audits/audit');
const assert = require('assert');

Expand All @@ -40,15 +40,15 @@ class TestGatherer extends Gather {

const fakeDriver = require('./fake-driver');

describe('Driver', function() {
describe('GatherRunner', function() {
it('loads a page', () => {
const driver = {
gotoURL() {
return Promise.resolve(true);
}
};

return Driver.loadPage(driver, {}, {
return GatherRunner.loadPage(driver, {}, {
flags: {
loadPage: true
}
Expand All @@ -62,7 +62,7 @@ describe('Driver', function() {
const driver = fakeDriver;
const options = {url, driver};

return Driver.run([], options).then(_ => {
return GatherRunner.run([], options).then(_ => {
assert.equal(typeof options.flags, 'object');
});
});
Expand All @@ -79,7 +79,7 @@ describe('Driver', function() {
}
};

return Driver.loadPage(driver, {url: 'https://example.com'})
return GatherRunner.loadPage(driver, {url: 'https://example.com'})
.then(res => {
assert.equal(res, true);
});
Expand All @@ -95,7 +95,7 @@ describe('Driver', function() {
forceUpdateServiceWorkers() {}
};

return Driver.setupDriver(driver, {}, {
return GatherRunner.setupDriver(driver, {}, {
flags: {
mobile: true
}
Expand All @@ -114,7 +114,7 @@ describe('Driver', function() {
forceUpdateServiceWorkers() {}
};

return Driver.setupDriver(driver, {}, {
return GatherRunner.setupDriver(driver, {}, {
flags: {}
}).then(_ => {
assert.equal(calledEmulation, false);
Expand All @@ -137,7 +137,7 @@ describe('Driver', function() {
}]
};

return Driver.setup({driver, config}).then(_ => {
return GatherRunner.setup({driver, config}).then(_ => {
assert.equal(calledTrace, true);
});
});
Expand All @@ -158,7 +158,7 @@ describe('Driver', function() {
}]
};

return Driver.afterPass({driver, config}).then(vals => {
return GatherRunner.afterPass({driver, config}).then(vals => {
assert.equal(calledTrace, true);
assert.deepEqual(vals.traces[Audit.DEFAULT_TRACE].traceContents, {x: 1});
});
Expand All @@ -179,7 +179,7 @@ describe('Driver', function() {
}]
};

return Driver.afterPass({driver, config}).then(vals => {
return GatherRunner.afterPass({driver, config}).then(vals => {
assert.deepEqual(vals.traces.notTheDefaultPass.traceContents, {x: 1});
});
});
Expand All @@ -200,7 +200,7 @@ describe('Driver', function() {
}]
};

return Driver.setup({driver, config}).then(_ => {
return GatherRunner.setup({driver, config}).then(_ => {
assert.equal(calledNetworkCollect, true);
});
});
Expand All @@ -221,18 +221,18 @@ describe('Driver', function() {
}]
};

return Driver.afterPass({driver, config}).then(vals => {
return GatherRunner.afterPass({driver, config}).then(vals => {
assert.equal(calledNetworkCollect, true);
assert.deepEqual(vals.networkRecords, {x: 1});
});
});

it('rejects when not given a URL', () => {
return Driver.run({}, {}).then(_ => assert.ok(false), _ => assert.ok(true));
return GatherRunner.run({}, {}).then(_ => assert.ok(false), _ => assert.ok(true));
});

it('rejects when given a URL of zero length', () => {
return Driver.run({}, {url: ''}).then(_ => assert.ok(false), _ => assert.ok(true));
return GatherRunner.run({}, {url: ''}).then(_ => assert.ok(false), _ => assert.ok(true));
});

it('does as many passes as are required', () => {
Expand All @@ -255,7 +255,7 @@ describe('Driver', function() {
]
}];

return Driver.run(passes, {driver: fakeDriver, url: 'https://example.com', flags: {}})
return GatherRunner.run(passes, {driver: fakeDriver, url: 'https://example.com', flags: {}})
.then(_ => {
assert.ok(t1.called);
assert.ok(t2.called);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const AccessibilityGather = require('../../../driver/gatherers/accessibility');
const AccessibilityGather = require('../../../gather/gatherers/accessibility');
const assert = require('assert');
let accessibilityGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const CacheContentGather = require('../../../driver/gatherers/cache-contents');
const CacheContentGather = require('../../../gather/gatherers/cache-contents');
const assert = require('assert');
let cacheContentGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const ContentWidthGatherer = require('../../../driver/gatherers/content-width');
const ContentWidthGatherer = require('../../../gather/gatherers/content-width');
const assert = require('assert');
let contentWidthGatherer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const GathererClass = require('../../../driver/gatherers/critical-request-chains');
const GathererClass = require('../../../gather/gatherers/critical-request-chains');
const assert = require('assert');
const Gatherer = new GathererClass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const Gather = require('../../../driver/gatherers/gather');
const Gather = require('../../../gather/gatherers/gather');
const assert = require('assert');

describe('Gather', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const GeolocationGatherer = require('../../../driver/gatherers/geolocation-on-start');
const GeolocationGatherer = require('../../../gather/gatherers/geolocation-on-start');
const assert = require('assert');
let geolocationGatherer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const HTMLWithoutJavaScriptGather = require('../../../driver/gatherers/html-without-javascript');
const HTMLWithoutJavaScriptGather = require('../../../gather/gatherers/html-without-javascript');
const assert = require('assert');
let htmlWithoutJavaScriptGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const HTMLGather = require('../../../driver/gatherers/html');
const HTMLGather = require('../../../gather/gatherers/html');
const assert = require('assert');
let htmlGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const HTTPRedirectGather = require('../../../driver/gatherers/http-redirect');
const HTTPRedirectGather = require('../../../gather/gatherers/http-redirect');
const assert = require('assert');
let httpRedirectGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const HTTPSGather = require('../../../driver/gatherers/https');
const HTTPSGather = require('../../../gather/gatherers/https');
const assert = require('assert');
let httpsGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const ManifestGather = require('../../../driver/gatherers/manifest');
const ManifestGather = require('../../../gather/gatherers/manifest');
const assert = require('assert');
let manifestGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const OfflineGather = require('../../../driver/gatherers/offline');
const OfflineGather = require('../../../gather/gatherers/offline');
const assert = require('assert');
let offlineGather;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const ScreenshotsGather = require('../../../driver/gatherers/screenshots');
const ScreenshotsGather = require('../../../gather/gatherers/screenshots');
const assert = require('assert');
let screenshotsGather = new ScreenshotsGather();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const ServiceWorkerGather = require('../../../driver/gatherers/service-worker');
const ServiceWorkerGather = require('../../../gather/gatherers/service-worker');
const assert = require('assert');
let serviceWorkerGatherer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const SpeedlineGather = require('../../../driver/gatherers/speedline.js');
const SpeedlineGather = require('../../../gather/gatherers/speedline.js');
const assert = require('assert');

describe('Speedline gatherer', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* eslint-env mocha */

const ThemeColorGather = require('../../../driver/gatherers/theme-color');
const ThemeColorGather = require('../../../gather/gatherers/theme-color');
const assert = require('assert');
let themeColorGather;

Expand Down
Loading

0 comments on commit 35d0360

Please sign in to comment.