Skip to content

Commit

Permalink
Adjust loader for trace files
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Jul 27, 2016
1 parent bfd880d commit 18bebe0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions lighthouse-core/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ function expandArtifacts(artifacts) {
const expandedArtifacts = Object.assign({}, artifacts);

// currently only trace logs and performance logs should be imported
if (artifacts.traceContents) {
expandedArtifacts.traceContents = require(artifacts.traceContents);
if (artifacts.traces) {
Object.keys(artifacts.traces).forEach(key => {
if (artifacts.traces[key].traceContents) {
expandedArtifacts.traces[key].traceContents =
require(artifacts.traces[key].traceContents);
}
});
}
if (artifacts.performanceLog) {
expandedArtifacts.CriticalRequestChains =
Expand Down
8 changes: 6 additions & 2 deletions lighthouse-core/test/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,16 @@ describe('Config', () => {
it('expands artifacts', () => {
const config = new Config({
artifacts: {
traceContents: path.resolve(__dirname, '../fixtures/traces/trace-user-timings.json'),
traces: {
firstPass: {
traceContents: path.resolve(__dirname, '../fixtures/traces/trace-user-timings.json')
}
},
performanceLog: path.resolve(__dirname, '../fixtures/perflog.json')
}
});
const traceUserTimings = require('../fixtures/traces/trace-user-timings.json');
assert.deepStrictEqual(config.artifacts.traceContents, traceUserTimings);
assert.deepStrictEqual(config.artifacts.traces.firstPass.traceContents, traceUserTimings);
assert.ok(config.artifacts.CriticalRequestChains);
assert.ok(config.artifacts.CriticalRequestChains['93149.1']);
assert.ok(config.artifacts.CriticalRequestChains['93149.1'].request);
Expand Down
6 changes: 5 additions & 1 deletion lighthouse-core/test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ describe('Runner', () => {
],

artifacts: {
traceContents: path.join(__dirname,
traces: {
firstPass: {
traceContents: path.join(__dirname,
'/fixtures/traces/trace-user-timings.json')
}
}
}
}, flags.auditWhitelist);

Expand Down

0 comments on commit 18bebe0

Please sign in to comment.