Skip to content

Commit

Permalink
test: fix fixtures test when run with env DUMPIO=1 (#4123)
Browse files Browse the repository at this point in the history
The DUMPIO env variable is propagated to a spawned process
and results in unfortunate stdout.
  • Loading branch information
aslushnikov committed Mar 13, 2019
1 parent 808d1bb commit 3511a35
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -7,7 +7,7 @@ module.exports = {
},

"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": 9
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -51,7 +51,7 @@
"@types/ws": "^6.0.1",
"commonmark": "^0.28.1",
"cross-env": "^5.0.5",
"eslint": "^5.9.0",
"eslint": "^5.15.1",
"esprima": "^4.0.0",
"jpeg-js": "^0.3.4",
"minimist": "^1.2.0",
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures.spec.js
Expand Up @@ -41,7 +41,11 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
});
it('should close the browser when the node process closes', async({ server }) => {
const {spawn, execSync} = require('child_process');
const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), puppeteerPath, JSON.stringify(defaultBrowserOptions)]);
const options = Object.assign({}, defaultBrowserOptions, {
// Disable DUMPIO to cleanly read stdout.
dumpio: false,
});
const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), puppeteerPath, JSON.stringify(options)]);
let wsEndPointCallback;
const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);
let output = '';
Expand Down
10 changes: 8 additions & 2 deletions utils/node6-transform/index.js
Expand Up @@ -22,14 +22,19 @@ const transformAsyncFunctions = require('./TransformAsyncFunctions');
const root = path.join(__dirname, '..', '..');
const dest = path.join(__dirname, '..', '..', 'node6');

const excludes = [
path.resolve(root, 'test', 'assets'),
];

if (fs.existsSync(dest))
removeRecursive(dest);
fs.mkdirSync(dest);
fs.mkdirSync(path.join(dest, 'utils'));

copyFolder(path.join(root, 'lib'), path.join(dest, 'lib'));
copyFolder(path.join(root, 'test'), path.join(dest, 'test'));
copyFolder(path.join(root, 'utils'), path.join(dest, 'utils'));
copyFolder(path.join(root, 'utils', 'testrunner'), path.join(dest, 'utils', 'testrunner'));
copyFolder(path.join(root, 'utils', 'testserver'), path.join(dest, 'utils', 'testserver'));

function copyFolder(source, target) {
if (fs.existsSync(target))
Expand All @@ -48,7 +53,8 @@ function copyFolder(source, target) {

function copyFile(from, to) {
let text = fs.readFileSync(from);
if (from.endsWith('.js')) {
const isExcluded = excludes.some(exclude => from.startsWith(exclude));
if (!isExcluded && from.endsWith('.js')) {
text = text.toString();
const prefix = text.startsWith('#!') ? text.substring(0, text.indexOf('\n')) : '';
text = prefix + transformAsyncFunctions(text.substring(prefix.length));
Expand Down

0 comments on commit 3511a35

Please sign in to comment.