Skip to content

Commit

Permalink
plots: smoke test for happy case (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen authored and paulirish committed Jun 13, 2017
1 parent 8770cac commit 1c5c57f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ script:
- yarn smoke
- yarn smokehouse
- yarn compile-devtools
- yarn plots-smoke
after_success:
- yarn coveralls
after_failure:
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/config/plots.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"first-meaningful-paint",
"speed-index-metric",
"estimated-input-latency",
"time-to-interactive",
"first-interactive",
"consistently-interactive"
]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"chrome": "node chrome-launcher/manual-chrome-launcher.js",
"fast": "yarn start -- --disable-device-emulation --disable-cpu-throttling --disable-network-throttling",
"smokehouse": "node lighthouse-cli/test/smokehouse/smokehouse.js",
"deploy-viewer": "cd lighthouse-viewer && gulp deploy"
"deploy-viewer": "cd lighthouse-viewer && gulp deploy",
"plots-smoke": "bash plots/test/smoke.sh"
},
"devDependencies": {
"@types/node": "^6.0.45",
Expand Down
3 changes: 3 additions & 0 deletions plots/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function main() {
GENERATED_RESULTS_PATH,
`var generatedResults = ${JSON.stringify(generatedResults)}`
);
if (process.env.CI) {
return;
}
console.log('Opening the charts web page...'); // eslint-disable-line no-console
opn(path.resolve(__dirname, 'index.html'));
}
Expand Down
18 changes: 14 additions & 4 deletions plots/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function main() {
if (args.reuseChrome) {
ChromeLauncher.launch().then(launcher => {
return runAnalysisWithExistingChromeInstances(launcher)
.catch(err => console.error(err))
.catch(handleError)
.then(() => launcher.kill());
});
return;
Expand Down Expand Up @@ -110,16 +110,26 @@ function runAnalysisWithNewChromeInstances() {
promise = promise.then(() => {
return ChromeLauncher.launch().then(launcher => {
return singleRunAnalysis(url, id, launcher, {ignoreRun})
.catch(err => console.error(err))
.catch(handleError)
.then(() => launcher.kill());
})
.catch(err => console.error(err));
.catch(handleError);
});
}
}
return promise;
}

/**
* @param {!Error} error
*/
function handleError(error) {
console.error(error);
if (process.env.CI) {
process.exit(1);
}
}

/**
* Reuses existing Chrome instance for all site runs.
* Returns a promise chain that analyzes all the sites n times.
Expand Down Expand Up @@ -195,7 +205,7 @@ function analyzeWithLighthouse(launcher, url, outputPath, assetsPath, {ignoreRun
return Printer.write(lighthouseResults, flags.output, outputPath);
});
})
.catch(err => console.error(err));
.catch(handleError);
}

/**
Expand Down
35 changes: 35 additions & 0 deletions plots/test/smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

##
# @license Copyright 2017 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
##

set -e

random_number="$(shuf -i 1-10000 -n 1)";

# paths
local_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
plots_path="$local_path/.."
out_path="$plots_path/out"
out_backup_folder="out_backup_$random_number"
out_backup_path="$plots_path/$out_backup_folder"

analyze_script="$plots_path/analyze.js"
clean_script="$plots_path/clean.js"
measure_script="$plots_path/measure.js"

echo "Starting plots smoke test"

if [ -d "$out_path" ]; then
mv $out_path $out_backup_path
echo "Moved existing plots/out folder to plots/$out_backup_folder"
fi

node $measure_script --site https://google.com/ -n 2 --disable-network-throttling --disable-cpu-throttling
node $analyze_script
node $clean_script

echo "Finished plots smoke test without errors"

0 comments on commit 1c5c57f

Please sign in to comment.