Skip to content

Commit fe5f57d

Browse files
Michael Gerakispaulirish
authored andcommitted
Travis: enable testing of node v4 + --harmony (#501)
1 parent 3585eef commit fe5f57d

File tree

6 files changed

+46
-11
lines changed

6 files changed

+46
-11
lines changed

.travis.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
language: node_js
2-
node_js:
3-
- "5.0"
4-
- "node"
2+
matrix:
3+
include:
4+
- node_js: "4.3.2"
5+
env:
6+
- UNIT=unit:harmony COVERALLS=coveralls:harmony
7+
- node_js: "5.0"
8+
env:
9+
- UNIT=unit COVERALLS=coveralls
10+
- node_js: "node"
11+
env:
12+
- UNIT=unit COVERALLS=coveralls
513
sudo: required
614
dist: trusty
715
cache:
@@ -18,9 +26,9 @@ before_script:
1826
- sleep 5
1927
script:
2028
- npm run lint
21-
- npm run unit
29+
- npm run $UNIT
2230
- npm run closure
23-
- npm run coveralls
31+
- npm run $COVERALLS
2432
- npm run smoke
2533
- cd lighthouse-extension
2634
- gulp build

lighthouse-cli/scripts/run-smoke-tests.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

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

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

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

1317
sleep 5s
1418

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

1725
if ! grep -q "URL responds with a 200 when offline: true" results; then
1826
echo "Fail! offline ready site did not work while offline"

lighthouse-cli/test/cli/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,30 @@
1919
/* eslint-env mocha */
2020
const assert = require('assert');
2121
const childProcess = require('child_process');
22+
let node = 'node';
2223

2324
describe('CLI Tests', function() {
25+
before(() => {
26+
if (/^v4.*/.test(process.version)) {
27+
node = 'node --harmony';
28+
}
29+
});
30+
2431
it('fails if a url is not provided', () => {
25-
assert.throws(() => childProcess.execSync('node lighthouse-cli/index.js'));
32+
assert.throws(() => childProcess.execSync(`${node} lighthouse-cli/index.js`),
33+
/Please provide a url/);
2634
});
2735

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

3543
it('accepts just the list-trace-categories flag and exit immediately after', () => {
3644
const output = JSON.parse(childProcess.execSync(
37-
'node lighthouse-cli/index.js --list-trace-categories').toString());
45+
`${node} lighthouse-cli/index.js --list-trace-categories`).toString());
3846
assert.ok(Array.isArray(output.traceCategories));
3947
assert.ok(output.traceCategories.length > 0);
4048
});

lighthouse-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"test": "npm run lint --silent && npm run unit && npm run closure",
1313
"watch": "find . -name '*.js' -not -path '*/node_modules/*' -not -path '*/extension/*' | entr npm run unit",
1414
"unit": "mocha $(find ./test -name '*.js') --timeout 60000",
15+
"unit:harmony": "mocha --harmony $(find ./test -name '*.js') --timeout 60000",
1516
"chrome": "./scripts/launch-chrome.sh"
1617
},
1718
"repository": "googlechrome/lighthouse",

lighthouse-extension/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"brfs": "^1.4.3",
1313
"browserify": "^13.0.0",
1414
"del": "^2.2.0",
15+
"eslint": "^2.4.0",
1516
"eslint-config-google": "^0.4.0",
1617
"gulp": "^3.9.1",
1718
"gulp-chrome-manifest": "0.0.13",
@@ -20,6 +21,7 @@
2021
"gulp-livereload": "^3.8.1",
2122
"gulp-rename": "^1.2.2",
2223
"gulp-tap": "^0.1.3",
24+
"gulp-util": "^3.0.7",
2325
"gulp-zip": "^3.2.0",
2426
"run-sequence": "^1.1.5",
2527
"through2": "^2.0.1"

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@
1313
"lint": "eslint .",
1414
"smoke": "lighthouse-cli/scripts/run-smoke-tests.sh",
1515
"coverage": "istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*.js') --timeout 60000",
16+
"coverage:harmony": "node --harmony node_modules/istanbul/lib/cli.js cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*.js') --timeout 60000",
1617
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
18+
"coveralls:harmony": "npm run coverage:harmony && cat ./coverage/lcov.info | coveralls",
1719
"start": "node ./lighthouse-cli/index.js",
18-
"test": "npm run lint --silent && npm run unit && npm run closure",
20+
"test": "if [[ $(node -v) =~ ^v4.* ]]; then npm run test:harmony; else npm run test:sans-harmony; fi",
21+
"test:sans-harmony": "npm run lint --silent && npm run unit && npm run closure",
22+
"test:harmony": "npm run lint --silent && npm run unit:harmony && npm run closure",
1923
"cli-unit": "mocha $(find lighthouse-cli/test -name '*.js') --timeout 60000",
24+
"cli-unit:harmony": "mocha --harmony $(find lighthouse-cli/test -name '*.js') --timeout 60000",
2025
"unit": "npm run cli-unit && npm --prefix ./lighthouse-core run unit",
26+
"unit:harmony": "npm run cli-unit:harmony && npm --prefix ./lighthouse-core run unit:harmony",
27+
"//":
28+
"// passing through tasks to core",
2129
"closure": "npm --prefix ./lighthouse-core run closure",
2230
"watch": "npm --prefix ./lighthouse-core run watch",
2331
"chrome": "npm --prefix ./lighthouse-core run chrome"

0 commit comments

Comments
 (0)