Skip to content

Commit

Permalink
make existing smoketest run using smokehouse (#788)
Browse files Browse the repository at this point in the history
* transfer npm run smoke to using smokehouse

* run smokehouse subprocess with --harmony if needed
  • Loading branch information
brendankenny authored and addyosmani committed Oct 18, 2016
1 parent b446a81 commit 41a5cfe
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 53 deletions.
49 changes: 0 additions & 49 deletions lighthouse-cli/scripts/run-smoke-tests.sh

This file was deleted.

3 changes: 1 addition & 2 deletions lighthouse-cli/test/fixtures/offline-ready-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
// A list of local resources we always want to be cached.
const PRECACHE_URLS = [
'./offline-ready.html',
'./offline-ready-sw.js',
'./smoketest-offline-config.json'
'./offline-ready-sw.js'
];

// Names of the two caches used in this version of the service worker.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @license
* Copyright 2016 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.
*/
'use strict';

/**
* Expected Lighthouse audit values for local test pages, one of which works
* offline with a service worker and one of which does not. Tests against audits
* defined in 'offline-config.json'.
*/
module.exports = [
{
initialUrl: 'http://localhost:10200/online-only.html',
url: 'http://localhost:10200/online-only.html',
audits: {
'service-worker': false,
'works-offline': false,
'viewport': true
}
},

{
initialUrl: 'http://localhost:10503/offline-ready.html',
url: 'http://localhost:10503/offline-ready.html',
audits: {
'service-worker': true,
'works-offline': true,
'viewport': true
}
}
];
17 changes: 17 additions & 0 deletions lighthouse-cli/test/smokehouse/offline-local/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

node lighthouse-cli/test/fixtures/static-server.js &

sleep 0.5s

config="lighthouse-cli/test/smokehouse/offline-local/offline-config.json"
expectations="lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js"

# run smoketest, expecting results found in offline-expectations
npm run -s smokehouse -- --config-path=$config --expectations-path=$expectations
exit_code=$?

# kill test servers
kill $(jobs -p)

exit "$exit_code"
5 changes: 4 additions & 1 deletion lighthouse-cli/test/smokehouse/smokehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ function resolveLocalOrCwd(payloadPath) {
* @return {!LighthouseResults}
*/
function runLighthouse(url, configPath) {
const command = `node lighthouse-cli/index.js ${url}`;
// Assume if currently running in Node v4 that child process will as well, so
// run Lighthouse with --harmony flag.
const harmony = /v4/.test(process.version) ? '--harmony' : '';
const command = `node ${harmony} lighthouse-cli/index.js ${url}`;
const options = [
`--config-path=${configPath}`,
'--output=json',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"lint": "[ \"$CI\" = true ] && eslint --quiet . || eslint .",
"smoke": "lighthouse-cli/scripts/run-smoke-tests.sh",
"smoke": "lighthouse-cli/test/smokehouse/offline-local/run-tests.sh",
"coverage": "node $__node_harmony $(npm bin)/istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*-test.js') --timeout 10000 --reporter progress",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"start": "node ./lighthouse-cli/index.js",
Expand Down

0 comments on commit 41a5cfe

Please sign in to comment.