Skip to content

Commit

Permalink
Travis: enable testing of node v4 + --harmony (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gerakis authored and paulirish committed Jul 12, 2016
1 parent 3585eef commit fe5f57d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
18 changes: 13 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
language: node_js
node_js:
- "5.0"
- "node"
matrix:
include:
- node_js: "4.3.2"
env:
- UNIT=unit:harmony COVERALLS=coveralls:harmony
- node_js: "5.0"
env:
- UNIT=unit COVERALLS=coveralls
- node_js: "node"
env:
- UNIT=unit COVERALLS=coveralls
sudo: required
dist: trusty
cache:
Expand All @@ -18,9 +26,9 @@ before_script:
- sleep 5
script:
- npm run lint
- npm run unit
- npm run $UNIT
- npm run closure
- npm run coveralls
- npm run $COVERALLS
- npm run smoke
- cd lighthouse-extension
- gulp build
12 changes: 10 additions & 2 deletions lighthouse-cli/scripts/run-smoke-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

cd lighthouse-cli/test/fixtures && python -m SimpleHTTPServer 9999 &

./lighthouse-cli/index.js http://localhost:9999/online-only.html > results
if [[ $(node -v) =~ ^v4.* ]]; then
node --harmony lighthouse-cli/index.js http://localhost:9999/online-only.html > results
else
./lighthouse-cli/index.js http://localhost:9999/online-only.html > results
fi

if ! grep -q "URL responds with a 200 when offline: false" results; then
echo "Fail! online only site worked while offline"
Expand All @@ -12,7 +16,11 @@ fi

sleep 5s

./lighthouse-cli/index.js https://www.moji-brush.com > results
if [[ $(node -v) =~ ^v4.* ]]; then
node --harmony lighthouse-cli/index.js https://www.moji-brush.com > results
else
./lighthouse-cli/index.js https://www.moji-brush.com > results
fi

if ! grep -q "URL responds with a 200 when offline: true" results; then
echo "Fail! offline ready site did not work while offline"
Expand Down
14 changes: 11 additions & 3 deletions lighthouse-cli/test/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,30 @@
/* eslint-env mocha */
const assert = require('assert');
const childProcess = require('child_process');
let node = 'node';

describe('CLI Tests', function() {
before(() => {
if (/^v4.*/.test(process.version)) {
node = 'node --harmony';
}
});

it('fails if a url is not provided', () => {
assert.throws(() => childProcess.execSync('node lighthouse-cli/index.js'));
assert.throws(() => childProcess.execSync(`${node} lighthouse-cli/index.js`),
/Please provide a url/);
});

it('should list all audits without a url and exit immediately after', () => {
const output = JSON.parse(childProcess.execSync(
'node lighthouse-cli/index.js --list-all-audits').toString());
`${node} lighthouse-cli/index.js --list-all-audits`).toString());
assert.ok(Array.isArray(output.audits));
assert.ok(output.audits.length > 0);
});

it('accepts just the list-trace-categories flag and exit immediately after', () => {
const output = JSON.parse(childProcess.execSync(
'node lighthouse-cli/index.js --list-trace-categories').toString());
`${node} lighthouse-cli/index.js --list-trace-categories`).toString());
assert.ok(Array.isArray(output.traceCategories));
assert.ok(output.traceCategories.length > 0);
});
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "npm run lint --silent && npm run unit && npm run closure",
"watch": "find . -name '*.js' -not -path '*/node_modules/*' -not -path '*/extension/*' | entr npm run unit",
"unit": "mocha $(find ./test -name '*.js') --timeout 60000",
"unit:harmony": "mocha --harmony $(find ./test -name '*.js') --timeout 60000",
"chrome": "./scripts/launch-chrome.sh"
},
"repository": "googlechrome/lighthouse",
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"brfs": "^1.4.3",
"browserify": "^13.0.0",
"del": "^2.2.0",
"eslint": "^2.4.0",
"eslint-config-google": "^0.4.0",
"gulp": "^3.9.1",
"gulp-chrome-manifest": "0.0.13",
Expand All @@ -20,6 +21,7 @@
"gulp-livereload": "^3.8.1",
"gulp-rename": "^1.2.2",
"gulp-tap": "^0.1.3",
"gulp-util": "^3.0.7",
"gulp-zip": "^3.2.0",
"run-sequence": "^1.1.5",
"through2": "^2.0.1"
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
"lint": "eslint .",
"smoke": "lighthouse-cli/scripts/run-smoke-tests.sh",
"coverage": "istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*.js') --timeout 60000",
"coverage:harmony": "node --harmony node_modules/istanbul/lib/cli.js cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*.js') --timeout 60000",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"coveralls:harmony": "npm run coverage:harmony && cat ./coverage/lcov.info | coveralls",
"start": "node ./lighthouse-cli/index.js",
"test": "npm run lint --silent && npm run unit && npm run closure",
"test": "if [[ $(node -v) =~ ^v4.* ]]; then npm run test:harmony; else npm run test:sans-harmony; fi",
"test:sans-harmony": "npm run lint --silent && npm run unit && npm run closure",
"test:harmony": "npm run lint --silent && npm run unit:harmony && npm run closure",
"cli-unit": "mocha $(find lighthouse-cli/test -name '*.js') --timeout 60000",
"cli-unit:harmony": "mocha --harmony $(find lighthouse-cli/test -name '*.js') --timeout 60000",
"unit": "npm run cli-unit && npm --prefix ./lighthouse-core run unit",
"unit:harmony": "npm run cli-unit:harmony && npm --prefix ./lighthouse-core run unit:harmony",
"//":
"// passing through tasks to core",
"closure": "npm --prefix ./lighthouse-core run closure",
"watch": "npm --prefix ./lighthouse-core run watch",
"chrome": "npm --prefix ./lighthouse-core run chrome"
Expand Down

0 comments on commit fe5f57d

Please sign in to comment.