diff --git a/configure b/configure index a07dc0f686a..e8531b4668f 100755 --- a/configure +++ b/configure @@ -12,10 +12,10 @@ exec python "$0" "$@" del _ import sys +from distutils.spawn import find_executable as which if sys.version_info[0] != 2 or sys.version_info[1] not in (6, 7): sys.stderr.write('Please use either Python 2.6 or 2.7') - from distutils.spawn import find_executable as which python2 = which('python2') or which('python2.6') or which('python2.7') if python2: @@ -1400,6 +1400,34 @@ def configure_engine(o): o['variables']['chakracore_use_lto'] = "false" o['variables']['chakracore_lto_build_flags'] = [ ] +def get_bin_override(): + # If the system python is not the python we are running (which should be + # python 2), then create a directory with a symlink called `python` to our + # sys.executable. This directory will be prefixed to the PATH, so that + # other tools that shell out to `python` will use the appropriate python + + if os.path.realpath(which('python')) == os.path.realpath(sys.executable): + return + + bin_override = os.path.abspath('out/tools/bin') + try: + os.makedirs(bin_override) + except OSError as e: + if e.errno != errno.EEXIST: raise e + + python_link = os.path.join(bin_override, 'python') + try: + os.unlink(python_link) + except OSError as e: + if e.errno != errno.ENOENT: raise e + os.symlink(sys.executable, python_link) + + # We need to set the environment right now so that when gyp (in run_gyp) + # shells out, it finds the right python (specifically at + # https://github.com/nodejs/node/blob/d82e107/deps/v8/gypfiles/toolchain.gypi#L43) + os.environ['PATH'] = bin_override + ':' + os.environ['PATH'] + + return bin_override output = { @@ -1481,6 +1509,10 @@ if options.prefix: config = '\n'.join(map('='.join, config.iteritems())) + '\n' +bin_override = get_bin_override() +if bin_override: + config = 'export PATH:=' + bin_override + ':$(PATH)\n' + config + write('config.mk', do_not_edit + config) gyp_args = ['--no-parallel'] diff --git a/deps/v8/src/inspector/v8-inspector-impl.cc b/deps/v8/src/inspector/v8-inspector-impl.cc index 0a7b19a36a7..4cdbba9c915 100644 --- a/deps/v8/src/inspector/v8-inspector-impl.cc +++ b/deps/v8/src/inspector/v8-inspector-impl.cc @@ -286,18 +286,22 @@ std::unique_ptr V8InspectorImpl::captureStackTrace( void V8InspectorImpl::asyncTaskScheduled(const StringView& taskName, void* task, bool recurring) { + if (!task) return; m_debugger->asyncTaskScheduled(taskName, task, recurring); } void V8InspectorImpl::asyncTaskCanceled(void* task) { + if (!task) return; m_debugger->asyncTaskCanceled(task); } void V8InspectorImpl::asyncTaskStarted(void* task) { + if (!task) return; m_debugger->asyncTaskStarted(task); } void V8InspectorImpl::asyncTaskFinished(void* task) { + if (!task) return; m_debugger->asyncTaskFinished(task); } diff --git a/doc/STYLE_GUIDE.md b/doc/STYLE_GUIDE.md index 69bfa86500d..27b66995b4c 100644 --- a/doc/STYLE_GUIDE.md +++ b/doc/STYLE_GUIDE.md @@ -6,8 +6,6 @@ topic the document will describe (e.g., `child_process`). * Filenames should be **lowercase**. * Some files, such as top-level markdown files, are exceptions. - * Older files may use the `.markdown` extension. These may be ported to `.md` - at will. **Prefer `.md` for all new documents.** * Documents should be word-wrapped at 80 characters. * The formatting described in `.editorconfig` is preferred. * A [plugin][] is available for some editors to automatically apply these diff --git a/test/inspector/test-exception.js b/test/inspector/test-exception.js index 4e10814008e..e82b9311bba 100644 --- a/test/inspector/test-exception.js +++ b/test/inspector/test-exception.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); +const fixtures = require('../common/fixtures'); common.skipIfInspectorDisabled(); const assert = require('assert'); const { NodeInstance } = require('./inspector-helper.js'); -const path = require('path'); -const script = path.join(common.fixturesDir, 'throws_error.js'); +const script = fixtures.path('throws_error.js'); async function testBreakpointOnStart(session) { console.log('[test]', diff --git a/test/parallel/test-benchmark-querystring.js b/test/parallel/test-benchmark-querystring.js new file mode 100644 index 00000000000..9daa165bf82 --- /dev/null +++ b/test/parallel/test-benchmark-querystring.js @@ -0,0 +1,11 @@ +'use strict'; + +require('../common'); + +const runBenchmark = require('../common/benchmark'); + +runBenchmark('querystring', [ + 'n=1', + 'input="there is nothing to unescape here"', + 'type=noencode' +]); diff --git a/test/parallel/test-error-reporting.js b/test/parallel/test-error-reporting.js index 7fa10cdb946..522d5f39171 100644 --- a/test/parallel/test-error-reporting.js +++ b/test/parallel/test-error-reporting.js @@ -23,10 +23,10 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -const path = require('path'); +const fixtures = require('../common/fixtures'); function errExec(script, callback) { - const cmd = `"${process.argv[0]}" "${path.join(common.fixturesDir, script)}"`; + const cmd = `"${process.argv[0]}" "${fixtures.path(script)}"`; return exec(cmd, function(err, stdout, stderr) { // There was some error assert.ok(err); diff --git a/test/parallel/test-fs-write-stream-encoding.js b/test/parallel/test-fs-write-stream-encoding.js index 3ce47b73829..5fb81088772 100644 --- a/test/parallel/test-fs-write-stream-encoding.js +++ b/test/parallel/test-fs-write-stream-encoding.js @@ -1,13 +1,14 @@ 'use strict'; const common = require('../common'); const assert = require('assert'); +const fixtures = require('../common/fixtures'); const fs = require('fs'); const path = require('path'); const stream = require('stream'); const firstEncoding = 'base64'; const secondEncoding = 'latin1'; -const examplePath = path.join(common.fixturesDir, 'x.txt'); +const examplePath = fixtures.path('x.txt'); const dummyPath = path.join(common.tmpDir, 'x.txt'); common.refreshTmpDir(); diff --git a/test/parallel/test-http-url.parse-https.request.js b/test/parallel/test-http-url.parse-https.request.js index b644e7530ff..87b7ac02e90 100644 --- a/test/parallel/test-http-url.parse-https.request.js +++ b/test/parallel/test-http-url.parse-https.request.js @@ -23,16 +23,16 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const { readKey } = require('../common/fixtures'); const assert = require('assert'); const https = require('https'); const url = require('url'); -const fs = require('fs'); // https options const httpsOptions = { - key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), - cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`) + key: readKey('agent1-key.pem'), + cert: readKey('agent1-cert.pem') }; function check(request) { diff --git a/test/parallel/test-http2-create-client-connect.js b/test/parallel/test-http2-create-client-connect.js index a9c63d02b3f..7fdea9aef41 100644 --- a/test/parallel/test-http2-create-client-connect.js +++ b/test/parallel/test-http2-create-client-connect.js @@ -5,9 +5,8 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); -const fs = require('fs'); +const fixtures = require('../common/fixtures'); const h2 = require('http2'); -const path = require('path'); const url = require('url'); const URL = url.URL; @@ -51,8 +50,8 @@ const URL = url.URL; { const options = { - key: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-key.pem')), - cert: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-cert.pem')) + key: fixtures.readKey('agent3-key.pem'), + cert: fixtures.readKey('agent3-cert.pem') }; const server = h2.createSecureServer(options); diff --git a/test/parallel/test-http2-https-fallback.js b/test/parallel/test-http2-https-fallback.js index 266c6f89f34..4dabe4e69db 100644 --- a/test/parallel/test-http2-https-fallback.js +++ b/test/parallel/test-http2-https-fallback.js @@ -1,13 +1,12 @@ 'use strict'; const common = require('../common'); +const fixtures = require('../common/fixtures'); if (!common.hasCrypto) common.skip('missing crypto'); const { strictEqual } = require('assert'); -const { join } = require('path'); -const { readFileSync } = require('fs'); const { createSecureContext } = require('tls'); const { createSecureServer, connect } = require('http2'); const { get } = require('https'); @@ -16,13 +15,9 @@ const { connect: tls } = require('tls'); const countdown = (count, done) => () => --count === 0 && done(); -function loadKey(keyname) { - return readFileSync(join(common.fixturesDir, 'keys', keyname)); -} - -const key = loadKey('agent8-key.pem'); -const cert = loadKey('agent8-cert.pem'); -const ca = loadKey('fake-startcom-root-cert.pem'); +const key = fixtures.readKey('agent8-key.pem'); +const cert = fixtures.readKey('agent8-cert.pem'); +const ca = fixtures.readKey('fake-startcom-root-cert.pem'); const clientOptions = { secureContext: createSecureContext({ ca }) }; diff --git a/test/parallel/test-http2-respond-file-fd.js b/test/parallel/test-http2-respond-file-fd.js index 29a5fe665de..303d25be3f2 100644 --- a/test/parallel/test-http2-respond-file-fd.js +++ b/test/parallel/test-http2-respond-file-fd.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); +const fixtures = require('../common/fixtures'); if (!common.hasCrypto) common.skip('missing crypto'); const http2 = require('http2'); const assert = require('assert'); -const path = require('path'); const fs = require('fs'); const { @@ -13,7 +13,7 @@ const { HTTP2_HEADER_CONTENT_LENGTH } = http2.constants; -const fname = path.resolve(common.fixturesDir, 'elipses.txt'); +const fname = fixtures.path('elipses.txt'); const data = fs.readFileSync(fname); const stat = fs.statSync(fname); const fd = fs.openSync(fname, 'r'); diff --git a/test/parallel/test-https-agent-create-connection.js b/test/parallel/test-https-agent-create-connection.js index 267030232dc..4ad3554f791 100644 --- a/test/parallel/test-https-agent-create-connection.js +++ b/test/parallel/test-https-agent-create-connection.js @@ -1,6 +1,7 @@ 'use strict'; const common = require('../common'); +const fixtures = require('../common/fixtures'); if (!common.hasCrypto) common.skip('missing crypto'); @@ -9,11 +10,9 @@ const https = require('https'); const agent = new https.Agent(); -const fs = require('fs'); - const options = { - key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), - cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`), + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem'), }; const expectedHeader = /^HTTP\/1\.1 200 OK/; diff --git a/test/parallel/test-https-agent-secure-protocol.js b/test/parallel/test-https-agent-secure-protocol.js index 4839dd7c460..4963b55febe 100644 --- a/test/parallel/test-https-agent-secure-protocol.js +++ b/test/parallel/test-https-agent-secure-protocol.js @@ -5,12 +5,12 @@ if (!common.hasCrypto) const assert = require('assert'); const https = require('https'); -const fs = require('fs'); +const fixtures = require('../common/fixtures'); const options = { - key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), - cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`), - ca: fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`) + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem'), + ca: fixtures.readKey('ca1-cert.pem') }; const server = https.Server(options, function(req, res) { diff --git a/test/parallel/test-https-agent-servername.js b/test/parallel/test-https-agent-servername.js index 625fa45c7c1..985fbb3ce3f 100644 --- a/test/parallel/test-https-agent-servername.js +++ b/test/parallel/test-https-agent-servername.js @@ -5,12 +5,12 @@ if (!common.hasCrypto) common.skip('missing crypto'); const https = require('https'); -const fs = require('fs'); +const fixtures = require('../common/fixtures'); const options = { - key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), - cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`), - ca: fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`) + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem'), + ca: fixtures.readKey('ca1-cert.pem') }; diff --git a/test/parallel/test-https-agent-sni.js b/test/parallel/test-https-agent-sni.js index a06ce439fa4..80278ed2d8f 100644 --- a/test/parallel/test-https-agent-sni.js +++ b/test/parallel/test-https-agent-sni.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); +const fixtures = require('../common/fixtures'); if (!common.hasCrypto) common.skip('missing crypto'); const assert = require('assert'); const https = require('https'); -const fs = require('fs'); const options = { - key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), - cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`) + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem') }; const TOTAL = 4; diff --git a/test/parallel/test-https-client-checkServerIdentity.js b/test/parallel/test-https-client-checkServerIdentity.js index 9842fc1f357..87c9ec8229f 100644 --- a/test/parallel/test-https-client-checkServerIdentity.js +++ b/test/parallel/test-https-client-checkServerIdentity.js @@ -25,13 +25,12 @@ if (!common.hasCrypto) common.skip('missing crypto'); const assert = require('assert'); +const fixtures = require('../common/fixtures'); const https = require('https'); -const fs = require('fs'); -const path = require('path'); const options = { - key: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-key.pem')), - cert: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-cert.pem')) + key: fixtures.readKey('agent3-key.pem'), + cert: fixtures.readKey('agent3-cert.pem') }; const server = https.createServer(options, common.mustCall(function(req, res) { @@ -46,7 +45,7 @@ function authorized() { const req = https.request({ port: server.address().port, rejectUnauthorized: true, - ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))] + ca: [fixtures.readKey('ca2-cert.pem')] }, common.mustNotCall()); req.on('error', function(err) { override(); @@ -58,7 +57,7 @@ function override() { const options = { port: server.address().port, rejectUnauthorized: true, - ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))], + ca: [fixtures.readKey('ca2-cert.pem')], checkServerIdentity: function(host, cert) { return false; } diff --git a/test/parallel/test-https-client-reject.js b/test/parallel/test-https-client-reject.js index 82a7851e4e1..729256df54f 100644 --- a/test/parallel/test-https-client-reject.js +++ b/test/parallel/test-https-client-reject.js @@ -24,14 +24,14 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const fixtures = require('../common/fixtures'); + const assert = require('assert'); const https = require('https'); -const fs = require('fs'); -const path = require('path'); const options = { - key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), - cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) + key: fixtures.readSync('test_key.pem'), + cert: fixtures.readSync('test_cert.pem') }; const server = https.createServer(options, common.mustCall(function(req, res) { @@ -72,7 +72,7 @@ function rejectUnauthorized() { function authorized() { const options = { port: server.address().port, - ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))] + ca: [fixtures.readSync('test_cert.pem')] }; options.agent = new https.Agent(options); const req = https.request(options, function(res) { diff --git a/test/parallel/test-https-req-split.js b/test/parallel/test-https-req-split.js index d0306cb714f..05fc85fc07b 100644 --- a/test/parallel/test-https-req-split.js +++ b/test/parallel/test-https-req-split.js @@ -21,6 +21,7 @@ 'use strict'; const common = require('../common'); +const fixtures = require('../common/fixtures'); if (!common.hasCrypto) common.skip('missing crypto'); @@ -30,11 +31,10 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; const https = require('https'); const tls = require('tls'); -const fs = require('fs'); const options = { - key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), - cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`) + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem') }; // Force splitting incoming data diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js index 0850f726363..39689a37eca 100644 --- a/test/parallel/test-internal-errors.js +++ b/test/parallel/test-internal-errors.js @@ -282,6 +282,20 @@ assert.strictEqual( 'Request path contains unescaped characters' ); +// Test ERR_DNS_SET_SERVERS_FAILED +assert.strictEqual( + errors.message('ERR_DNS_SET_SERVERS_FAILED', ['err', 'servers']), + 'c-ares failed to set servers: "err" [servers]'); + +// Test ERR_ENCODING_NOT_SUPPORTED +assert.strictEqual( + errors.message('ERR_ENCODING_NOT_SUPPORTED', ['enc']), + 'The "enc" encoding is not supported'); + +// Test ERR_HTTP2_HEADER_REQUIRED +assert.strictEqual( + errors.message('ERR_HTTP2_HEADER_REQUIRED', ['test']), + 'The test header is required'); // Test error messages for async_hooks assert.strictEqual( diff --git a/test/parallel/test-internal-modules.js b/test/parallel/test-internal-modules.js index 2f11ca18dd6..c61d957acd0 100644 --- a/test/parallel/test-internal-modules.js +++ b/test/parallel/test-internal-modules.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); -const path = require('path'); +require('../common'); +const fixtures = require('../common/fixtures'); const assert = require('assert'); assert.throws(function() { @@ -8,6 +8,6 @@ assert.throws(function() { }, /^Error: Cannot find module 'internal\/freelist'$/); assert.strictEqual( - require(path.join(common.fixturesDir, 'internal-modules')), + require(fixtures.path('internal-modules')), 42 ); diff --git a/test/parallel/test-tls-pfx-gh-5100-regr.js b/test/parallel/test-tls-pfx-gh-5100-regr.js index dc72b42aa0d..199d4bdf227 100644 --- a/test/parallel/test-tls-pfx-gh-5100-regr.js +++ b/test/parallel/test-tls-pfx-gh-5100-regr.js @@ -17,11 +17,7 @@ const server = tls.createServer({ requestCert: true, rejectUnauthorized: false }, common.mustCall(function(c) { - assert.strictEqual( - c.authorizationError, - null, - 'authorizationError must be null' - ); + assert.strictEqual(c.authorizationError, null); c.end(); })).listen(0, function() { const client = tls.connect({