Skip to content

Commit

Permalink
config double passname validation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Apr 29, 2017
1 parent 3339e1e commit f0481df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lighthouse-cli/test/smokehouse/pwa-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
module.exports = {
passes: [{
ecordTrace: true,
recordTrace: true,
gatherers: [
'url',
'theme-color',
Expand Down
6 changes: 1 addition & 5 deletions lighthouse-core/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,9 @@ function validatePasses(passes, audits, rootPath) {
});
});

// Log if multiple passes require trace could overwrite one another.
// Passes should have unique passName's. Warn otherwise.
const usedNames = new Set();
passes.forEach((pass, index) => {
if (!pass.recordTrace) {
return;
}

const passName = pass.passName || Audit.DEFAULT_PASS;
if (usedNames.has(passName)) {
log.warn('config', `passes[${index}] may overwrite trace ` +
Expand Down
5 changes: 4 additions & 1 deletion lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ describe('Config', () => {
return new Promise((resolve, reject) => {
const warningListener = function(args) {
const warningMsg = args[1];
if (new RegExp(`overwrite.+${unlikelyPassName}`).test(warningMsg)) {
const isMatch = new RegExp(`overwrite.+${unlikelyPassName}`).test(warningMsg);
if (isMatch) {
log.events.removeListener('warning', warningListener);
resolve();
} else {
reject(isMatch);
}
};
log.events.addListener('warning', warningListener);
Expand Down

0 comments on commit f0481df

Please sign in to comment.