Skip to content

Commit

Permalink
Test node6 on travis (puppeteer#551)
Browse files Browse the repository at this point in the history
This patch starts running all puppeteer tests with node6 on travis-ci.
  • Loading branch information
JoelEinbinder authored and aslushnikov committed Aug 26, 2017
1 parent bd5b4fe commit cd81944
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
third_party/*
utils/doclint/check_public_api/test/
node6/*
node6/*
node6-test/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
.vscode
package-lock.json
/node6
/node6-test
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ node_modules
*.pyc
.vscode
package-lock.json
/node6-test
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ install:
script:
- 'if [ "$NODE7" = "true" ]; then yarn run lint; fi'
- 'if [ "$NODE7" = "true" ]; then yarn run coverage; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run node6; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run test-node6; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run node6-sanity; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run test-node6-transformer; fi'
- 'if [ "$NODE6" = "true" ]; then yarn run unit-node6; fi'
jobs:
include:
- node_js: "7"
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
"unit": "jasmine test/test.js",
"debug-unit": "DEBUG_TEST=true node --inspect-brk ./node_modules/.bin/jasmine test/test.js",
"test-doclint": "jasmine utils/doclint/check_public_api/test/test.js && jasmine utils/doclint/preprocessor/test.js",
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6",
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer",
"install": "node install.js",
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .) && npm run doc",
"doc": "node utils/doclint/cli.js",
"coverage": "COVERAGE=true npm run unit",
"node6": "node utils/node6-transform/index.js",
"test-node6": "jasmine utils/node6-transform/test/test.js",
"build": "npm run node6",
"node6-sanity": "jasmine test/sanity.js"
"test-node6-transformer": "jasmine utils/node6-transform/test/test.js",
"build": "node utils/node6-transform/index.js",
"unit-node6": "jasmine node6-test/test.js"
},
"author": "The Chromium Authors",
"license": "SEE LICENSE IN LICENSE",
Expand Down
33 changes: 0 additions & 33 deletions test/sanity.js

This file was deleted.

1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const path = require('path');
const helper = require('../lib/helper');
if (process.env.COVERAGE)
helper.recordPublicAPICoverage();
console.log('Testing on Node', process.version);
const puppeteer = require('..');
const SimpleServer = require('./server/SimpleServer');
const GoldenUtils = require('./golden-utils');
Expand Down
1 change: 1 addition & 0 deletions utils/node6-transform/TransformAsyncFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const asyncToGenerator = fn => {

/**
* @param {string} text
* @return {string}
*/
function transformAsyncFunctions(text) {
const edits = [];
Expand Down
31 changes: 19 additions & 12 deletions utils/node6-transform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@ const path = require('path');
const removeRecursive = require('rimraf').sync;
const transformAsyncFunctions = require('./TransformAsyncFunctions');

const dirPath = path.join(__dirname, '..', '..', 'lib');
const outPath = path.join(__dirname, '..', '..', 'node6');
const fileNames = fs.readdirSync(dirPath);
const filePaths = fileNames.filter(fileName => fileName.endsWith('.js'));
copyFolder(path.join(__dirname, '..', '..', 'lib'), path.join(__dirname, '..', '..', 'node6'));
copyFolder(path.join(__dirname, '..', '..', 'test'), path.join(__dirname, '..', '..', 'node6-test'));

if (fs.existsSync(outPath))
removeRecursive(outPath);
fs.mkdirSync(outPath);

filePaths.forEach(filePath => {
const content = fs.readFileSync(path.join(dirPath, filePath), 'utf8');
const output = transformAsyncFunctions(content);
fs.writeFileSync(path.resolve(outPath, filePath), output);
});
function copyFolder(source, target) {
if (fs.existsSync(target))
removeRecursive(target);
fs.mkdirSync(target);

fs.readdirSync(source).forEach(file => {
const from = path.join(source, file);
const to = path.join(target, file);
if (fs.lstatSync(from).isDirectory()) {
copyFolder(from, to);
} else {
let text = fs.readFileSync(from);
if (file.endsWith('.js'))
text = transformAsyncFunctions(text.toString()).replace(/require\('\.\.\/lib\//g, `require('../node6/`);
fs.writeFileSync(to, text);
}
});
}

0 comments on commit cd81944

Please sign in to comment.