Skip to content

Commit

Permalink
misc: rename lantern master values to baseline values (#10950)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Feb 24, 2021
1 parent 11d33bb commit a985a7e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const chalk = require('chalk').default;

const INPUT_PATH = process.argv[2] || constants.SITE_INDEX_WITH_GOLDEN_WITH_COMPUTED_PATH;
const HEAD_PATH = path.resolve(process.cwd(), INPUT_PATH);
const MASTER_PATH = constants.MASTER_COMPUTED_PATH;
const MASTER_ACCURACY_PATH = constants.MASTER_ACCURACY_PATH;
const BASELINE_PATH = constants.BASELINE_COMPUTED_PATH;
const BASELINE_ACCURACY_PATH = constants.BASELINE_ACCURACY_PATH;

if (!fs.existsSync(HEAD_PATH) || !fs.existsSync(MASTER_PATH)) {
if (!fs.existsSync(HEAD_PATH) || !fs.existsSync(BASELINE_PATH)) {
throw new Error('Usage $0 <computed file>');
}

const computedResults = require(HEAD_PATH);
const expectedResults = require(MASTER_PATH);
const expectedResults = require(BASELINE_PATH);

/** @type {Array<{url: string, maxDiff: number, diffsForSite: Array<DiffForSite>}>} */
const diffs = [];
Expand Down Expand Up @@ -58,7 +58,7 @@ if (diffs.length) {
const metric = ` - ${entry.metricName.padEnd(25)}`;
const diff = entry.diff > 0 ? chalk.yellow(`+${entry.diff}`) : chalk.cyan(`${entry.diff}`);
const actual = `${entry.actual} ${chalk.gray('(HEAD)')}`;
const expected = `${entry.expected} ${chalk.gray('(master)')}`;
const expected = `${entry.expected} ${chalk.gray('(baseline)')}`;
console.log(`${metric}${diff}\t${actual}\tvs.\t${expected}`);
});
});
Expand All @@ -67,7 +67,7 @@ if (diffs.length) {
} else {
assert.deepStrictEqual(
constants.evaluateAllMetrics(computedResults, expectedResults),
require(MASTER_ACCURACY_PATH)
require(BASELINE_ACCURACY_PATH)
);
console.log('✅ PASS No changes between expected and computed!');
}
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/scripts/lantern/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ module.exports = {
// prettier-ignore
SITE_INDEX_WITH_GOLDEN_WITH_COMPUTED_PATH: path.join(__dirname, '../../../.tmp/site-index-plus-golden-expectations-plus-computed.json'),
// prettier-ignore
MASTER_COMPUTED_PATH: path.join(__dirname, '../../test/fixtures/lantern-master-computed-values.json'),
BASELINE_COMPUTED_PATH: path.join(__dirname, '../../test/fixtures/lantern-baseline-computed-values.json'),
// prettier-ignore
MASTER_ACCURACY_PATH: path.join(__dirname, '../../test/fixtures/lantern-master-accuracy.json'),
BASELINE_ACCURACY_PATH: path.join(__dirname, '../../test/fixtures/lantern-baseline-accuracy.json'),
/**
* @param {{sites: Array<LanternSiteDefinition>}} siteIndexWithComputed
* @param {{sites: Array<LanternMetrics & {url: string}>}} baselineLanternData
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-core/scripts/lantern/print-correlations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ const OK_DIFF_AS_PERCENT_THRESHOLD = 0.5;

const INPUT_PATH = process.argv[2] || constants.SITE_INDEX_WITH_GOLDEN_WITH_COMPUTED_PATH;
const COMPUTATIONS_PATH = path.resolve(process.cwd(), INPUT_PATH);
const BASELINE_PATH = constants.MASTER_COMPUTED_PATH;

const BASELINE_PATH = constants.BASELINE_COMPUTED_PATH;

if (!fs.existsSync(COMPUTATIONS_PATH)) throw new Error('Usage $0 <computed summary file>');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const INPUT_PATH = process.argv[2] || constants.SITE_INDEX_WITH_GOLDEN_PATH;
const SITE_INDEX_PATH = path.resolve(process.cwd(), INPUT_PATH);
const HEAD_COMPUTED_PATH = constants.SITE_INDEX_WITH_GOLDEN_WITH_COMPUTED_PATH;
const RUN_ALL_SCRIPT_PATH = path.join(__dirname, 'run-on-all-assets.js');
const OUTPUT_PATH = constants.MASTER_COMPUTED_PATH;
const OUTPUT_ACCURACY_PATH = constants.MASTER_ACCURACY_PATH;
const OUTPUT_PATH = constants.BASELINE_COMPUTED_PATH;
const OUTPUT_ACCURACY_PATH = constants.BASELINE_ACCURACY_PATH;

if (!fs.existsSync(HEAD_COMPUTED_PATH) || process.env.FORCE) {
if (!fs.existsSync(SITE_INDEX_PATH)) throw new Error('Usage $0 <expectations file>');
Expand Down Expand Up @@ -47,5 +47,3 @@ fs.writeFileSync(OUTPUT_ACCURACY_PATH, JSON.stringify(
null,
2
));


4 changes: 2 additions & 2 deletions lighthouse-core/scripts/test-lantern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ printf "\n\nRunning lantern on all sites...\n"
printf "\n\n"
"$LH_ROOT/lighthouse-core/scripts/lantern/print-correlations.js"

printf "\n\nComparing to master computed values...\n"
"$LH_ROOT/lighthouse-core/scripts/lantern/assert-master-lantern-values-unchanged.js"
printf "\n\nComparing to baseline computed values...\n"
"$LH_ROOT/lighthouse-core/scripts/lantern/assert-baseline-lantern-values-unchanged.js"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"type-check": "tsc -p . && tsc -p lighthouse-viewer/ && tsc -p lighthouse-treemap/",
"i18n:checks": "./lighthouse-core/scripts/i18n/assert-strings-collected.sh",
"i18n:collect-strings": "node lighthouse-core/scripts/i18n/collect-strings.js",
"update:lantern-master": "node lighthouse-core/scripts/lantern/update-master-lantern-values.js",
"update:lantern-baseline": "node lighthouse-core/scripts/lantern/update-baseline-lantern-values.js",
"update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
"update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
"update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
Expand Down

0 comments on commit a985a7e

Please sign in to comment.