From 3511a35fa49f3d1c72123754aa06e3fb06c71073 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 13 Mar 2019 16:26:28 -0700 Subject: [PATCH] test: fix fixtures test when run with env DUMPIO=1 (#4123) The DUMPIO env variable is propagated to a spawned process and results in unfortunate stdout. --- .eslintrc.js | 2 +- package.json | 2 +- test/fixtures.spec.js | 6 +++++- utils/node6-transform/index.js | 10 ++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 632a158a..a6939035 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,7 @@ module.exports = { }, "parserOptions": { - "ecmaVersion": 8 + "ecmaVersion": 9 }, /** diff --git a/package.json b/package.json index 0b6cb0b6..8324b1bc 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/fixtures.spec.js b/test/fixtures.spec.js index 392e8479..ef421cd9 100644 --- a/test/fixtures.spec.js +++ b/test/fixtures.spec.js @@ -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 = ''; diff --git a/utils/node6-transform/index.js b/utils/node6-transform/index.js index 22bc3f07..967899f9 100644 --- a/utils/node6-transform/index.js +++ b/utils/node6-transform/index.js @@ -22,6 +22,10 @@ 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); @@ -29,7 +33,8 @@ 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)) @@ -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));