diff --git a/BUILDING.md b/BUILDING.md index c6e8656a72c..a4aa0808237 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -87,7 +87,14 @@ To test if Node.js was built correctly: $ node -e "console.log('Hello from Node.js ' + process.version)" ``` -### Android / Android based devices, aka. Firefox OS +### Android / Android-based devices (e.g., Firefox OS) + +Although these instructions for building on Android are provided, please note +that Android is not an officially supported platform at this time. Patches to +improve the Android build are accepted. However, there is no testing on Android +in the current continuous integration environment. The participation of people +dedicated and determined to improve Android building, testing, and support is +encouraged. Be sure you have downloaded and extracted [Android NDK] (https://developer.android.com/tools/sdk/ndk/index.html) diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 0ec424d45a1..2337353cb7b 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -63,10 +63,9 @@ A guide for Collaborators is maintained in ## CTC Membership -CTC seats are not time-limited. There is no fixed size of the CTC. -However, the expected target is between 6 and 12, to ensure adequate -coverage of important areas of expertise, balanced with the ability to -make decisions efficiently. +CTC seats are not time-limited. There is no fixed size of the CTC. The CTC +should be of such a size as to ensure adequate coverage of important areas of +expertise balanced with the ability to make decisions efficiently. There is no specific set of requirements or qualifications for CTC membership beyond these rules. diff --git a/LICENSE b/LICENSE index b39df1e0a8d..e6cd5888864 100644 --- a/LICENSE +++ b/LICENSE @@ -506,7 +506,7 @@ The externally maintained libraries used by Node.js are: - OpenSSL, located at deps/openssl, is licensed as follows: """ - Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + Copyright (c) 1998-2016 The OpenSSL Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/Makefile b/Makefile index f8fa9d992ea..6ab762d31da 100644 --- a/Makefile +++ b/Makefile @@ -516,6 +516,8 @@ bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events bench: bench-net bench-http bench-fs bench-tls +bench-ci: bench + bench-http-simple: benchmark/http_simple_bench.sh @@ -555,9 +557,11 @@ cpplint: lint: jslint cpplint +lint-ci: lint + .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \ check uninstall install install-includes install-bin all staticlib \ dynamiclib test test-all test-addons build-addons website-upload pkg \ blog blogclean tar binary release-only bench-http-simple bench-idle \ bench-all bench bench-misc bench-array bench-buffer bench-net \ - bench-http bench-fs bench-tls cctest run-ci + bench-http bench-fs bench-tls cctest run-ci lint-ci bench-ci diff --git a/README.md b/README.md index 5e805ca55d2..20c24dee60b 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,15 @@ documentation of the latest stable version. Stable, LTS and Nightly download directories all contain a *SHASUM256.txt* file that lists the SHA checksums for each file available for -download. To check that a downloaded file matches the checksum, run +download. + +The *SHASUM256.txt* can be downloaded using curl. + +``` +$ curl -O https://nodejs.org/dist/vx.y.z/SHASUMS256.txt +``` + +To check that a downloaded file matches the checksum, run it through `sha256sum` with a command such as: ``` @@ -114,8 +122,8 @@ Node.js from source. * [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) * [CONTRIBUTING.md](./CONTRIBUTING.md) * [GOVERNANCE.md](./GOVERNANCE.md) -* IRC (general questions): [#node.js on Freenode.net](http://webchat.freenode.net?channels=node.js&uio=d4) -* IRC (node core development): [#node-dev on Freenode.net](http://webchat.freenode.net?channels=node-dev&uio=d4) +* IRC (general questions): [#node.js on Freenode.net](https://webchat.freenode.net?channels=node.js&uio=d4) +* IRC (node core development): [#node-dev on Freenode.net](https://webchat.freenode.net?channels=node-dev&uio=d4) * [nodejs/node on Gitter](https://gitter.im/nodejs/node) ## Security diff --git a/common.gypi b/common.gypi index 6e32c253232..5b85018a332 100644 --- a/common.gypi +++ b/common.gypi @@ -14,6 +14,8 @@ 'node_tag%': '', 'uv_library%': 'static_library', + 'openssl_fips%': '', + # Default to -O0 for debug builds. 'v8_optimized_debug%': 0, diff --git a/doc/api/all.markdown b/doc/api/all.markdown index 8bac0103c88..93c7a300a16 100644 --- a/doc/api/all.markdown +++ b/doc/api/all.markdown @@ -5,6 +5,7 @@ @include buffer @include child_process @include cluster +@include cli @include console @include crypto @include debugger diff --git a/doc/api/assert.markdown b/doc/api/assert.markdown index 6bbbf6bd629..35dbc3d2192 100644 --- a/doc/api/assert.markdown +++ b/doc/api/assert.markdown @@ -361,8 +361,13 @@ If the values are not strictly equal, an `AssertionError` is thrown with a ## assert.throws(block[, error][, message]) -Expects the function `block` to throw an error. If specified, `error` can be a -constructor, [`RegExp`][], or validation function. +Expects the function `block` to throw an error. + +If specified, `error` can be a constructor, [`RegExp`][], or validation +function. + +If specified, `message` will be the message provided by the `AssertionError` if +the block fails to throw. Validate instanceof using constructor: @@ -402,6 +407,18 @@ assert.throws( ); ``` +Note that `error` can not be a string. If a string is provided as the second +argument, then `error` is assumed to be omitted and the string will be used for +`message` instead. This can lead to easy-to-miss mistakes: + +```js +// THIS IS A MISTAKE! DO NOT DO THIS! +assert.throws(myFunction, 'missing foo', 'did not throw with expected message'); + +// Do this instead. +assert.throws(myFunction, /missing foo/, 'did not throw with expected message'); +``` + [Locked]: documentation.html#documentation_stability_index [`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message [`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index 6d39ffdba84..4e6cdd546d8 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -739,8 +739,10 @@ const buf = new Buffer([1,-2,3,4]); buf.readInt32BE(); // returns 33424132 -buf.readInt32LE(1); +buf.readInt32LE(); // returns 67370497 +buf.readInt32LE(1); + // throws RangeError: Index out of range ``` ### buf.readIntBE(offset, byteLength[, noAssert]) @@ -1031,7 +1033,8 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeDoubleBE()` writes big endian, `writeDoubleLE()` writes little -endian). The `value` argument must be a valid 64-bit double. +endian). The `value` argument *should* be a valid 64-bit double. Behavior is +not defined when `value` is anything other than a 64-bit double. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1063,7 +1066,7 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeFloatBE()` writes big endian, `writeFloatLE()` writes little -endian). Behavior is unspecified if `value` is anything other than a 32-bit +endian). Behavior is not defined when `value` is anything other than a 32-bit float. Set `noAssert` to true to skip validation of `value` and `offset`. This means @@ -1093,8 +1096,9 @@ console.log(buf); * `noAssert` {Boolean} Default: false * Return: {Number} The offset plus the number of written bytes -Writes `value` to the Buffer at the specified `offset`. The `value` must be a -valid signed 8-bit integer. +Writes `value` to the Buffer at the specified `offset`. The `value` should be a +valid signed 8-bit integer. Behavior is not defined when `value` is anything +other than a signed 8-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1121,7 +1125,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeInt16BE()` writes big endian, `writeInt16LE()` writes little -endian). The `value` must be a valid signed 16-bit integer. +endian). The `value` should be a valid signed 16-bit integer. Behavior is +not defined when `value` is anything other than a signed 16-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1148,7 +1153,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeInt32BE()` writes big endian, `writeInt32LE()` writes little -endian). The `value` must be a valid signed 32-bit integer. +endian). The `value` should be a valid signed 32-bit integer. Behavior is +not defined when `value` is anything other than a signed 32-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1194,6 +1200,8 @@ that `value` may be too large for the specific function and `offset` may be beyond the end of the Buffer leading to the values being silently dropped. This should not be used unless you are certain of correctness. +Behavior is not defined when `value` is anything other than an integer. + ### buf.writeUInt8(value, offset[, noAssert]) * `value` {Number} Bytes to be written to Buffer @@ -1201,8 +1209,9 @@ should not be used unless you are certain of correctness. * `noAssert` {Boolean} Default: false * Return: {Number} The offset plus the number of written bytes -Writes `value` to the Buffer at the specified `offset`. The `value` must be a -valid unsigned 8-bit integer. +Writes `value` to the Buffer at the specified `offset`. The `value` should be a +valid unsigned 8-bit integer. Behavior is not defined when `value` is anything +other than an unsigned 8-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1232,7 +1241,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeUInt16BE()` writes big endian, `writeUInt16LE()` writes little -endian). The `value` must be a valid unsigned 16-bit integer. +endian). The `value` should be a valid unsigned 16-bit integer. Behavior is +not defined when `value` is anything other than an unsigned 16-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1266,7 +1276,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeUInt32BE()` writes big endian, `writeUInt32LE()` writes little -endian). The `value` must be a valid unsigned 32-bit integer. +endian). The `value` should be a valid unsigned 32-bit integer. Behavior is +not defined when `value` is anything other than an unsigned 32-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1312,6 +1323,8 @@ that `value` may be too large for the specific function and `offset` may be beyond the end of the Buffer leading to the values being silently dropped. This should not be used unless you are certain of correctness. +Behavior is not defined when `value` is anything other than an unsigned integer. + ## buffer.INSPECT_MAX_BYTES * {Number} Default: 50 diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index d8b5bc0f17f..7f03ed38284 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -130,8 +130,8 @@ exec('my.bat', (err, stdout, stderr) => { * `gid` {Number} Sets the group identity of the process. (See setgid(2).) * `callback` {Function} called with the output when process terminates * `error` {Error} - * `stdout` {Buffer} - * `stderr` {Buffer} + * `stdout` {String|Buffer} + * `stderr` {String|Buffer} * Return: {ChildProcess} Spawns a shell then executes the `command` within that shell, buffering any @@ -156,6 +156,13 @@ the exit code of the child process while `error.signal` will be set to the signal that terminated the process. Any exit code other than `0` is considered to be an error. +The `stdout` and `stderr` arguments passed to the callback will contain the +stdout and stderr output of the child process. By default, Node.js will decode +the output as UTF-8 and pass strings to the callback. The `encoding` option +can be used to specify the character encoding used to decode the stdout and +stderr output. If `encoding` is `'buffer'`, `Buffer` objects will be passed to +the callback instead. + The `options` argument may be passed as the second argument to customize how the process is spawned. The default options are: @@ -197,8 +204,8 @@ replace the existing process and uses a shell to execute the command.* * `gid` {Number} Sets the group identity of the process. (See setgid(2).) * `callback` {Function} called with the output when process terminates * `error` {Error} - * `stdout` {Buffer} - * `stderr` {Buffer} + * `stdout` {String|Buffer} + * `stderr` {String|Buffer} * Return: {ChildProcess} The `child_process.execFile()` function is similar to [`child_process.exec()`][] @@ -219,6 +226,13 @@ const child = execFile('node', ['--version'], (error, stdout, stderr) => { }); ``` +The `stdout` and `stderr` arguments passed to the callback will contain the +stdout and stderr output of the child process. By default, Node.js will decode +the output as UTF-8 and pass strings to the callback. The `encoding` option +can be used to specify the character encoding used to decode the stdout and +stderr output. If `encoding` is `'buffer'`, `Buffer` objects will be passed to +the callback instead. + ### child_process.fork(modulePath[, args][, options]) * `modulePath` {String} The module to run in the child diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index d176a482274..29fd956a779 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -286,7 +286,7 @@ cipher text should be discarded due to failed authentication. ### decipher.setAutoPadding(auto_padding=true) When data has been encrypted without standard block padding, calling -`decipher.setAuthPadding(false)` will disable automatic padding to prevent +`decipher.setAutoPadding(false)` will disable automatic padding to prevent [`decipher.final()`][] from checking for and removing padding. Turning auto padding off will only work if the input data's length is a @@ -719,6 +719,28 @@ console.log(sign.sign(private_key, 'hex')); // Prints the calculated signature ``` +A [`sign`][] instance can also be created by just passing in the digest +algorithm name, in which case OpenSSL will infer the full signature algorithm +from the type of the PEM-formatted private key, including algorithms that +do not have directly exposed name constants, e.g. 'ecdsa-with-SHA256'. + +Example: signing using ECDSA with SHA256 + +```js +const crypto = require('crypto'); +const sign = crypto.createSign('sha256'); + +sign.update('some data to sign'); + +const private_key = '-----BEGIN EC PRIVATE KEY-----\n' + + 'MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49\n' + + 'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2\n' + + 'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==\n' + + '-----END EC PRIVATE KEY-----\n'; + +console.log(sign.sign(private_key).toString('hex')); +``` + ### sign.sign(private_key[, output_format]) Calculates the signature on all the data passed through using either diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 9ee5e489837..1bee7d0cf98 100644 --- a/doc/api/globals.markdown +++ b/doc/api/globals.markdown @@ -30,6 +30,16 @@ console.log(__dirname); `__dirname` isn't actually a global but rather local to each module. +For instance, given two modules: `a` and `b`, where `b` is a dependency of +`a` and there is a directory structure of: + +* `/Users/mjr/app/a.js` +* `/Users/mjr/app/node_modules/b/b.js` + +References to `__dirname` within `b.js` will return +`/Users/mjr/app/node_modules/b` while references to `__dirname` within `a.js` +will return `/Users/mj/app`. + ## \_\_filename @@ -50,19 +60,23 @@ console.log(__filename); `__filename` isn't actually a global but rather local to each module. -## clearInterval(t) +## clearImmediate(immediateObject) + + + +[`clearImmediate`] is described in the [timers][] section. -Stop a timer that was previously created with [`setInterval()`][]. The callback -will not execute. +## clearInterval(intervalObject) -The timer functions are global variables. See the [timers][] section. +[`clearInterval`] is described in the [timers][] section. -## clearTimeout(t) +## clearTimeout(timeoutObject) -Stop a timer that was previously created with [`setTimeout()`][]. The callback will -not execute. + + +[`clearTimeout`] is described in the [timers][] section. ## console @@ -162,34 +176,33 @@ left untouched. Use the internal `require()` machinery to look up the location of a module, but rather than loading the module, just return the resolved filename. -## setInterval(cb, ms) +## setImmediate(callback[, arg][, ...]) + + -Run callback `cb` repeatedly every `ms` milliseconds. Note that the actual -interval may vary, depending on external factors like OS timer granularity and -system load. It's never less than `ms` but it may be longer. +[`setImmediate`] is described in the [timers][] section. -The interval must be in the range of 1-2,147,483,647 inclusive. If the value is -outside that range, it's changed to 1 millisecond. Broadly speaking, a timer -cannot span more than 24.8 days. +## setInterval(callback, delay[, arg][, ...]) -Returns an opaque value that represents the timer. + -## setTimeout(cb, ms) +[`setInterval`] is described in the [timers][] section. -Run callback `cb` after *at least* `ms` milliseconds. The actual delay depends -on external factors like OS timer granularity and system load. +## setTimeout(callback, delay[, arg][, ...]) -The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is -outside that range, it's changed to 1 millisecond. Broadly speaking, a timer -cannot span more than 24.8 days. + -Returns an opaque value that represents the timer. +[`setTimeout`] is described in the [timers][] section. [`console`]: console.html [`process` object]: process.html#process_process -[`setInterval()`]: #globals_setinterval_cb_ms -[`setTimeout()`]: #globals_settimeout_cb_ms [buffer section]: buffer.html [module system documentation]: modules.html [Modules]: modules.html#modules_modules [timers]: timers.html +[`clearImmediate`]: timers.html#timers_clearimmediate_immediateobject +[`clearInterval`]: timers.html#timers_clearinterval_intervalobject +[`clearTimeout`]: timers.html#timers_cleartimeout_timeoutobject +[`setImmediate`]: timers.html#timers_setimmediate_callback_arg +[`setInterval`]: timers.html#timers_setinterval_callback_delay_arg +[`setTimeout`]: timers.html#timers_settimeout_callback_delay_arg diff --git a/doc/api/path.markdown b/doc/api/path.markdown index e691d041458..8ebb5fd08a5 100644 --- a/doc/api/path.markdown +++ b/doc/api/path.markdown @@ -92,7 +92,7 @@ and the `base` property. If the `dir` property is not supplied, the `root` property will be used as the `dir` property. However, it will be assumed that the `root` property already ends with the platform-dependent path separator. In this case, the returned -string will be the concatenation fo the `root` property and the `base` property. +string will be the concatenation of the `root` property and the `base` property. If both the `dir` and the `root` properties are not supplied, then the returned string will be the contents of the `base` property. @@ -102,28 +102,41 @@ and the `ext` property will be used as the `base` property. Examples: -An example on Posix systems: +Some Posix system examples: ```js +// If `dir` and `base` are provided, `dir` + platform separator + `base` +// will be returned. path.format({ - root : "/", - dir : "/home/user/dir", - base : "file.txt", - ext : ".txt", - name : "file" + dir: '/home/user/dir', + base: 'file.txt' }); // returns '/home/user/dir/file.txt' -// `root` will be used if `dir` is not specified and `name` + `ext` will be used -// if `base` is not specified +// `root` will be used if `dir` is not specified. +// `name` + `ext` will be used if `base` is not specified. +// If only `root` is provided or `dir` is equal to `root` then the +// platform separator will not be included. path.format({ - root : "/", - ext : ".txt", - name : "file" -}) + root: '/', + base: 'file.txt' +}); // returns '/file.txt' -``` +path.format({ + dir: '/', + root: '/', + name: 'file', + ext: '.txt' +}); +// returns '/file.txt' + +// `base` will be returned if `dir` or `root` are not provided. +path.format({ + base: 'file.txt' +}); +// returns 'file.txt' +``` An example on Windows: ```js diff --git a/doc/api/timers.markdown b/doc/api/timers.markdown index 7859e7fecd6..3990ab6c1d3 100644 --- a/doc/api/timers.markdown +++ b/doc/api/timers.markdown @@ -27,7 +27,7 @@ Returns the timer. ## setImmediate(callback[, arg][, ...]) -To schedule the "immediate" execution of `callback` after I/O events' +Schedules "immediate" execution of `callback` after I/O events' callbacks and before timers set by [`setTimeout`][] and [`setInterval`][] are triggered. Returns an `immediateObject` for possible use with [`clearImmediate`][]. Additional optional arguments may be passed to the @@ -40,7 +40,7 @@ until the next event loop iteration. ## setInterval(callback, delay[, arg][, ...]) -To schedule the repeated execution of `callback` every `delay` milliseconds. +Schedules repeated execution of `callback` every `delay` milliseconds. Returns a `intervalObject` for possible use with [`clearInterval`][]. Additional optional arguments may be passed to the callback. @@ -50,7 +50,7 @@ milliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the ## setTimeout(callback, delay[, arg][, ...]) -To schedule execution of a one-time `callback` after `delay` milliseconds. +Schedules execution of a one-time `callback` after `delay` milliseconds. Returns a `timeoutObject` for possible use with [`clearTimeout`][]. Additional optional arguments may be passed to the callback. diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index 47f33923959..b093b2c3fe1 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -5,7 +5,6 @@ html { -webkit-font-variant-ligatures: none; font-variant-ligatures: none; height: 100%; - overflow: hidden; } body { @@ -15,9 +14,8 @@ body { padding: 0; color: #333; background: #fff; - overflow: hidden; + overflow: auto; height: 100%; - display: block; } pre, tt, code, .pre, span.type, a.type { @@ -27,7 +25,6 @@ pre, tt, code, .pre, span.type, a.type { #content { font-size: 1.8em; overflow: hidden; - display: block; position: relative; height: 100%; } @@ -426,7 +423,7 @@ a code { } span > .mark, span > .mark:visited { - font-size: 18px; + font-size: 1em; color: #707070; position: absolute; top: 0px; @@ -458,16 +455,15 @@ th > *:last-child, td > *:last-child { @media only screen and (max-width: 1024px) { #content { - font-size: 2.1em; + font-size: 2.5em; + overflow: visible; } #column1.interior { margin-left: 0; padding-left: .5em; padding-right: .5em; width: auto; - } - pre { - margin-right: 0; + overflow-y: visible; } #column2 { display: none; @@ -476,18 +472,6 @@ th > *:last-child, td > *:last-child { @media only screen and (max-width: 1024px) and (orientation: portrait) { #content { - font-size: 2.4em; - } - #column1.interior { - margin-left: 0; - padding-left: .5em; - padding-right: .5em; - width: auto; - } - pre { - margin-right: 0; - } - #column2 { - display: none; + font-size: 3.5em; } } diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index 152a7c65a63..cb4684f0edd 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -119,10 +119,10 @@ Client.prototype._transform = function _transform(data, enc, cb) { while (true) { if (this.state === 'headers') { // Not enough data - if (!/\r\n/.test(this.buffer)) + if (!this.buffer.includes('\r\n')) break; - if (/^\r\n/.test(this.buffer)) { + if (this.buffer.startsWith('\r\n')) { this.buffer = this.buffer.slice(2); this.state = 'body'; continue; diff --git a/lib/_debugger.js b/lib/_debugger.js index 3681ce58802..2bb9b7834cd 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -1342,7 +1342,7 @@ Interface.prototype.setBreakpoint = function(script, line, } let req; - if (/\(\)$/.test(script)) { + if (script.endsWith('()')) { // setBreakpoint('functionname()'); req = { type: 'function', diff --git a/lib/assert.js b/lib/assert.js index b33dbfa6cd1..d9e107688ad 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -29,6 +29,7 @@ const compare = process.binding('buffer').compare; const util = require('util'); const Buffer = require('buffer').Buffer; const pSlice = Array.prototype.slice; +const pToString = (obj) => Object.prototype.toString.call(obj); // 1. The assert module provides functions that throw // AssertionError's when particular conditions are not met. The @@ -170,10 +171,18 @@ function _deepEqual(actual, expected, strict) { (expected === null || typeof expected !== 'object')) { return strict ? actual === expected : actual == expected; - // If both values are instances of typed arrays, wrap them in - // a Buffer each to increase performance - } else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected)) { - return compare(new Buffer(actual), new Buffer(expected)) === 0; + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(new Buffer(actual.buffer), + new Buffer(expected.buffer)) === 0; // 7.5 For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified diff --git a/lib/cluster.js b/lib/cluster.js index 4f7ca581704..e4bbd5f3ff7 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -237,9 +237,8 @@ function masterInit() { // Without --logfile=v8-%p.log, everything ends up in a single, unusable // file. (Unusable because what V8 logs are memory addresses and each // process has its own memory mappings.) - if (settings.execArgv.some(function(s) { return /^--prof/.test(s); }) && - !settings.execArgv.some(function(s) { return /^--logfile=/.test(s); })) - { + if (settings.execArgv.some((s) => s.startsWith('--prof')) && + !settings.execArgv.some((s) => s.startsWith('--logfile='))) { settings.execArgv = settings.execArgv.concat(['--logfile=v8-%p.log']); } cluster.settings = settings; diff --git a/lib/dns.js b/lib/dns.js index 5a87b8c865f..d577023b50c 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -241,7 +241,7 @@ function resolver(bindingName) { } -var resolveMap = {}; +var resolveMap = Object.create(null); exports.resolve4 = resolveMap.A = resolver('queryA'); exports.resolve6 = resolveMap.AAAA = resolver('queryAaaa'); exports.resolveCname = resolveMap.CNAME = resolver('queryCname'); diff --git a/lib/internal/socket_list.js b/lib/internal/socket_list.js index 950d632a263..0f4be6df239 100644 --- a/lib/internal/socket_list.js +++ b/lib/internal/socket_list.js @@ -58,13 +58,11 @@ SocketListSend.prototype.getConnections = function getConnections(callback) { function SocketListReceive(slave, key) { EventEmitter.call(this); - var self = this; - this.connections = 0; this.key = key; this.slave = slave; - function onempty() { + function onempty(self) { if (!self.slave.connected) return; self.slave.send({ @@ -73,21 +71,21 @@ function SocketListReceive(slave, key) { }); } - this.slave.on('internalMessage', function(msg) { - if (msg.key !== self.key) return; + this.slave.on('internalMessage', (msg) => { + if (msg.key !== this.key) return; if (msg.cmd === 'NODE_SOCKET_NOTIFY_CLOSE') { // Already empty - if (self.connections === 0) return onempty(); + if (this.connections === 0) return onempty(this); // Wait for sockets to get closed - self.once('empty', onempty); + this.once('empty', onempty); } else if (msg.cmd === 'NODE_SOCKET_GET_COUNT') { - if (!self.slave.connected) return; - self.slave.send({ + if (!this.slave.connected) return; + this.slave.send({ cmd: 'NODE_SOCKET_COUNT', - key: self.key, - count: self.connections + key: this.key, + count: this.connections }); } }); @@ -95,14 +93,12 @@ function SocketListReceive(slave, key) { util.inherits(SocketListReceive, EventEmitter); SocketListReceive.prototype.add = function(obj) { - var self = this; - this.connections++; // Notify previous owner of socket about its state change - obj.socket.once('close', function() { - self.connections--; + obj.socket.once('close', () => { + this.connections--; - if (self.connections === 0) self.emit('empty'); + if (this.connections === 0) this.emit('empty', this); }); }; diff --git a/lib/os.js b/lib/os.js index ddf7cee9d48..42ece99a7d2 100644 --- a/lib/os.js +++ b/lib/os.js @@ -24,23 +24,23 @@ exports.platform = function() { return process.platform; }; -const trailingSlashRe = isWindows ? /[^:]\\$/ - : /.\/$/; - exports.tmpdir = function() { var path; if (isWindows) { path = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + '\\temp'; + if (path.length > 1 && path.endsWith('\\') && !path.endsWith(':\\')) + path = path.slice(0, -1); } else { path = process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp'; + if (path.length > 1 && path.endsWith('/')) + path = path.slice(0, -1); } - if (trailingSlashRe.test(path)) - path = path.slice(0, -1); + return path; }; diff --git a/lib/querystring.js b/lib/querystring.js index b034635668f..62404b75c7a 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -138,7 +138,12 @@ QueryString.escape = function(str) { } // Surrogate pair ++i; - c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF)); + var c2; + if (i < str.length) + c2 = str.charCodeAt(i) & 0x3FF; + else + throw new URIError('URI malformed'); + c = 0x10000 + (((c & 0x3FF) << 10) | c2); out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + diff --git a/lib/readline.js b/lib/readline.js index 8ee10850e54..74656896314 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -330,7 +330,7 @@ Interface.prototype._normalWrite = function(b) { this._line_buffer = null; } if (newPartContainsEnding) { - this._sawReturn = /\r$/.test(string); + this._sawReturn = string.endsWith('\r'); // got one or more newlines; process into "line" events var lines = string.split(lineEnding); diff --git a/lib/repl.js b/lib/repl.js index 0dc8a574523..bff367929ff 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -437,7 +437,7 @@ function REPLServer(prompt, debug('finish', e, ret); self.memory(cmd); - if (e && !self.bufferedCommand && cmd.trim().match(/^npm /)) { + if (e && !self.bufferedCommand && cmd.trim().startsWith('npm ')) { self.outputStream.write('npm should be run outside of the ' + 'node repl, in your normal shell.\n' + '(Press Control-D to exit.)\n'); diff --git a/lib/tls.js b/lib/tls.js index aad17c9ef2d..c87929f96ae 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -60,7 +60,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { // Create regexp to much hostnames function regexpify(host, wildcards) { // Add trailing dot (make hostnames uniform) - if (!/\.$/.test(host)) host += '.'; + if (!host || !host.endsWith('.')) host += '.'; // The same applies to hostname with more than one wildcard, // if hostname has wildcard when wildcards are not allowed, @@ -129,7 +129,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { } } else if (cert.subject) { // Transform hostname to canonical form - if (!/\.$/.test(host)) host += '.'; + if (!host || !host.endsWith('.')) host += '.'; // Otherwise check all DNS/URI records from certificate // (with allowed wildcards) diff --git a/src/node_win32_etw_provider-inl.h b/src/node_win32_etw_provider-inl.h index de53203cb3c..3fef20cc148 100644 --- a/src/node_win32_etw_provider-inl.h +++ b/src/node_win32_etw_provider-inl.h @@ -94,6 +94,13 @@ extern int events_enabled; dataDescriptors); \ CHECK_EQ(status, ERROR_SUCCESS); +#define ETW_WRITE_EMPTY_EVENT(eventDescriptor) \ + DWORD status = event_write(node_provider, \ + &eventDescriptor, \ + 0, \ + NULL); \ + CHECK_EQ(status, ERROR_SUCCESS); + void NODE_HTTP_SERVER_REQUEST(node_dtrace_http_server_request_t* req, node_dtrace_connection_t* conn, const char *remote, int port, @@ -189,10 +196,7 @@ void NODE_V8SYMBOL_MOVE(const void* addr1, const void* addr2) { void NODE_V8SYMBOL_RESET() { if (events_enabled > 0) { - int val = 0; - EVENT_DATA_DESCRIPTOR descriptors[1]; - ETW_WRITE_INT32_DATA(descriptors, &val); - ETW_WRITE_EVENT(NODE_V8SYMBOL_RESET_EVENT, descriptors); + ETW_WRITE_EMPTY_EVENT(NODE_V8SYMBOL_RESET_EVENT); } } @@ -244,7 +248,7 @@ void NODE_V8SYMBOL_ADD(LPCSTR symbol, line, col, symbuf, - symbol_len * sizeof(symbuf[0])); + (symbol_len + 1) * sizeof(symbuf[0])); ETW_WRITE_EVENT(MethodLoad, descriptors); } } diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index 972c94707ee..fe65405c858 100644 --- a/test/debugger/test-debugger-client.js +++ b/test/debugger/test-debugger-client.js @@ -73,7 +73,7 @@ var d = 'Content-Length: 466\r\n\r\n' + '"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' + '[{"handle":0' + ',"type":"context","text":"#"}],"running":true}' + - 'Content-Length: 119\r\n\r\n' + + '\r\n\r\nContent-Length: 119\r\n\r\n' + '{"seq":11,"type":"event","event":"scriptCollected","success":true,' + '"body":{"script":{"id":26}},"refs":[],"running":true}'; p.execute(d); diff --git a/test/parallel/test-dns-cares-domains.js b/test/internet/test-dns-cares-domains.js similarity index 100% rename from test/parallel/test-dns-cares-domains.js rename to test/internet/test-dns-cares-domains.js diff --git a/test/known_issues/test-stdin-is-always-net.socket.js b/test/known_issues/test-stdin-is-always-net.socket.js new file mode 100644 index 00000000000..78c1a7d2eac --- /dev/null +++ b/test/known_issues/test-stdin-is-always-net.socket.js @@ -0,0 +1,19 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/pull/5916 + +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; +const net = require('net'); + +if (process.argv[2] === 'child') { + assert(process.stdin instanceof net.Socket); + return; +} + +const proc = spawn(process.execPath, [__filename, 'child'], {stdio: 'ignore'}); +// To double-check this test, set stdio to 'pipe' and uncomment the line below. +// proc.stderr.pipe(process.stderr); +proc.on('exit', common.mustCall(function(exitCode) { + process.exitCode = exitCode; +})); diff --git a/test/known_issues/test-stdout-buffer-flush-on-exit.js b/test/known_issues/test-stdout-buffer-flush-on-exit.js new file mode 100644 index 00000000000..f4ea0b5e01b --- /dev/null +++ b/test/known_issues/test-stdout-buffer-flush-on-exit.js @@ -0,0 +1,20 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/issues/2148 + +require('../common'); +const assert = require('assert'); +const execSync = require('child_process').execSync; + +const longLine = 'foo bar baz quux quuz aaa bbb ccc'.repeat(65536); + +if (process.argv[2] === 'child') { + process.on('exit', () => { + console.log(longLine); + }); + process.exit(); +} + +const cmd = `${process.execPath} ${__filename} child`; +const stdout = execSync(cmd).toString().trim(); + +assert.strictEqual(stdout, longLine); diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js index 68edefdc175..be4462de5df 100644 --- a/test/parallel/test-assert-typedarray-deepequal.js +++ b/test/parallel/test-assert-typedarray-deepequal.js @@ -20,13 +20,25 @@ const equalArrayPairs = [ [new Int16Array(1e5), new Int16Array(1e5)], [new Int32Array(1e5), new Int32Array(1e5)], [new Float32Array(1e5), new Float32Array(1e5)], - [new Float64Array(1e5), new Float64Array(1e5)] + [new Float64Array(1e5), new Float64Array(1e5)], + [new Int16Array(256), new Uint16Array(256)], + [new Int16Array([256]), new Uint16Array([256])], + [new Float32Array([+0.0]), new Float32Array([-0.0])], + [new Float64Array([+0.0]), new Float32Array([-0.0])], + [new Float64Array([+0.0]), new Float64Array([-0.0])] ]; const notEqualArrayPairs = [ [new Uint8Array(2), new Uint8Array(3)], [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])], - [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])] + [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])], + [new Uint16Array([2]), new Uint16Array([3])], + [new Uint16Array([0]), new Uint16Array([256])], + [new Int16Array([0]), new Uint16Array([256])], + [new Int16Array([-256]), new Uint16Array([0xff00])], // same bits + [new Int32Array([-256]), new Uint32Array([0xffffff00])], // ditto + [new Float32Array([0.1]), new Float32Array([0.0])], + [new Float64Array([0.1]), new Float64Array([0.0])] ]; equalArrayPairs.forEach((arrayPair) => { diff --git a/test/parallel/test-c-ares.js b/test/parallel/test-c-ares.js index b7802881f8e..9a061bab1ac 100644 --- a/test/parallel/test-c-ares.js +++ b/test/parallel/test-c-ares.js @@ -27,6 +27,11 @@ assert.throws(function() { dns.resolve('www.google.com', 'HI'); }, /Unknown type/); +// Try calling resolve with an unsupported type that's an object key +assert.throws(function() { + dns.resolve('www.google.com', 'toString'); +}, /Unknown type/); + // Windows doesn't usually have an entry for localhost 127.0.0.1 in // C:\Windows\System32\drivers\etc\hosts // so we disable this test on Windows. diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 04264907d30..9a2577ec90d 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var dns = require('dns'); +const dns = require('dns'); var existing = dns.getServers(); assert(existing.length); @@ -121,27 +121,27 @@ assert.doesNotThrow(function() { }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { family: 4, hints: 0 }, noop); }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { family: 6, hints: dns.ADDRCONFIG }, noop); }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { hints: dns.V4MAPPED }, noop); }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { hints: dns.ADDRCONFIG | dns.V4MAPPED }, noop); }); diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index e76e8d08791..4dd979dafea 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -6,8 +6,9 @@ try { return; } -// the missing var keyword is intentional -domain = require('domain'); +// Pollution of global is intentional as part of test. +// See https://github.com/nodejs/node/commit/d1eff9ab +global.domain = require('domain'); // should not throw a 'TypeError: undefined is not a function' exception crypto.randomBytes(8); diff --git a/test/parallel/test-http-set-timeout.js b/test/parallel/test-http-set-timeout.js index 9bda60b2226..ca238de4314 100644 --- a/test/parallel/test-http-set-timeout.js +++ b/test/parallel/test-http-set-timeout.js @@ -20,7 +20,7 @@ server.listen(common.PORT, function() { var errorTimer = setTimeout(function() { throw new Error('Timeout was not successful'); - }, 2000); + }, common.platformTimeout(2000)); var x = http.get({port: common.PORT, path: '/'}); x.on('error', function() { diff --git a/test/parallel/test-https-agent.js b/test/parallel/test-https-agent.js index a3bb28975a3..9dea313e42e 100644 --- a/test/parallel/test-https-agent.js +++ b/test/parallel/test-https-agent.js @@ -23,8 +23,8 @@ var server = https.Server(options, function(req, res) { var responses = 0; -var N = 10; -var M = 10; +var N = 4; +var M = 4; server.listen(common.PORT, function() { for (var i = 0; i < N; i++) { diff --git a/test/parallel/test-net-socket-timeout-unref.js b/test/parallel/test-net-socket-timeout-unref.js index b7ed0ec344a..bbc2dffcc15 100644 --- a/test/parallel/test-net-socket-timeout-unref.js +++ b/test/parallel/test-net-socket-timeout-unref.js @@ -1,39 +1,35 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var server = net.createServer(function(c) { +// Test that unref'ed sockets with timeouts do not prevent exit. + +const common = require('../common'); +const net = require('net'); + +const server = net.createServer(function(c) { c.write('hello'); c.unref(); }); server.listen(common.PORT); server.unref(); -var timedout = false; var connections = 0; -var sockets = []; -var delays = [8, 5, 3, 6, 2, 4]; +const sockets = []; +const delays = [8, 5, 3, 6, 2, 4]; delays.forEach(function(T) { - var socket = net.createConnection(common.PORT, 'localhost'); - socket.on('connect', function() { + const socket = net.createConnection(common.PORT, 'localhost'); + socket.on('connect', common.mustCall(function() { if (++connections === delays.length) { sockets.forEach(function(s) { - s[0].setTimeout(s[1] * 1000, function() { - timedout = true; - s[0].destroy(); + s.socket.setTimeout(s.timeout, function() { + s.socket.destroy(); + throw new Error('socket timed out unexpectedly'); }); - s[0].unref(); + s.socket.unref(); }); } - }); - - sockets.push([socket, T]); -}); + })); -process.on('exit', function() { - assert.strictEqual(timedout, false, - 'Socket timeout should not hold loop open'); + sockets.push({socket: socket, timeout: T * 1000}); }); diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js index f15b20c0231..7cae61d71bc 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -41,7 +41,7 @@ server.listen(common.PORT, function() { }); var timer = setTimeout(function() { process.exit(1); - }, 200); + }, common.platformTimeout(200)); }); process.on('exit', function() { diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index b4388852499..2db59be1750 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -139,6 +139,11 @@ qsWeirdObjects.forEach(function(testCase) { assert.equal(testCase[1], qs.stringify(testCase[0])); }); +// invalid surrogate pair throws URIError +assert.throws(function() { + qs.stringify({ foo: '\udc00' }); +}, URIError); + // coerce numbers to string assert.strictEqual('foo=0', qs.stringify({ foo: 0 })); assert.strictEqual('foo=0', qs.stringify({ foo: -0 })); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 3d2cab6334b..33530cf1058 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -15,7 +15,7 @@ const prompt_npm = 'npm should be run outside of the ' + 'node repl, in your normal shell.\n' + '(Press Control-D to exit.)\n'; const expect_npm = prompt_npm + prompt_unix; -var server_tcp, server_unix, client_tcp, client_unix, timer, replServer; +var server_tcp, server_unix, client_tcp, client_unix, replServer; // absolute path to test/fixtures/a.js @@ -24,7 +24,7 @@ var moduleFilename = require('path').join(common.fixturesDir, 'a'); console.error('repl test'); // function for REPL to run -invoke_me = function(arg) { +global.invoke_me = function(arg) { return 'invoked ' + arg; }; @@ -45,7 +45,6 @@ function send_expect(list) { function clean_up() { client_tcp.end(); client_unix.end(); - clearTimeout(timer); } function strict_mode_error_test() { @@ -449,7 +448,3 @@ function unix_test() { } unix_test(); - -timer = setTimeout(function() { - assert.fail(null, null, 'Timeout'); -}, 5000); diff --git a/test/parallel/test-stdin-pipe-large.js b/test/parallel/test-stdin-pipe-large.js new file mode 100644 index 00000000000..428bbb04302 --- /dev/null +++ b/test/parallel/test-stdin-pipe-large.js @@ -0,0 +1,23 @@ +'use strict'; +// See https://github.com/nodejs/node/issues/5927 + +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; + +if (process.argv[2] === 'child') { + process.stdin.pipe(process.stdout); + return; +} + +const child = spawn(process.execPath, [__filename, 'child'], { stdio: 'pipe' }); + +const expectedBytes = 1024 * 1024; +let readBytes = 0; + +child.stdin.end(Buffer(expectedBytes)); + +child.stdout.on('data', (chunk) => readBytes += chunk.length); +child.stdout.on('end', common.mustCall(() => { + assert.strictEqual(readBytes, expectedBytes); +})); diff --git a/test/parallel/test-stdout-close-unref.js b/test/parallel/test-stdout-close-unref.js index 37ab4987eeb..67c6141c963 100644 --- a/test/parallel/test-stdout-close-unref.js +++ b/test/parallel/test-stdout-close-unref.js @@ -1,16 +1,30 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; -var errs = 0; +if (process.argv[2] === 'child') { + var errs = 0; -process.stdin.resume(); -process.stdin._handle.close(); -process.stdin._handle.unref(); // Should not segfault. -process.stdin.on('error', function(err) { - errs++; -}); + process.stdin.resume(); + process.stdin._handle.close(); + process.stdin._handle.unref(); // Should not segfault. + process.stdin.on('error', function(err) { + errs++; + }); -process.on('exit', function() { - assert.strictEqual(errs, 1); -}); + process.on('exit', function() { + assert.strictEqual(errs, 1); + }); + return; +} + +// Use spawn so that we can be sure that stdin has a _handle property. +// Refs: https://github.com/nodejs/node/pull/5916 +const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'pipe' }); + +proc.stderr.pipe(process.stderr); +proc.on('exit', common.mustCall(function(exitCode) { + if (exitCode !== 0) + process.exitCode = exitCode; +})); diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js index a5f5ad9415a..143e4e12216 100644 --- a/test/parallel/test-vm-static-this.js +++ b/test/parallel/test-vm-static-this.js @@ -14,25 +14,25 @@ assert.throws(function() { vm.runInThisContext('throw new Error(\'test\');'); }, /test/); -hello = 5; +global.hello = 5; vm.runInThisContext('hello = 2'); -assert.equal(2, hello); +assert.equal(2, global.hello); console.error('pass values'); -code = 'foo = 1;' + +var code = 'foo = 1;' + 'bar = 2;' + 'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');'; -foo = 2; -obj = { foo: 0, baz: 3 }; +global.foo = 2; +global.obj = { foo: 0, baz: 3 }; /* eslint-disable no-unused-vars */ var baz = vm.runInThisContext(code); /* eslint-enable no-unused-vars */ -assert.equal(0, obj.foo); -assert.equal(2, bar); -assert.equal(1, foo); +assert.equal(0, global.obj.foo); +assert.equal(2, global.bar); +assert.equal(1, global.foo); console.error('call a function'); -f = function() { foo = 100; }; +global.f = function() { global.foo = 100; }; vm.runInThisContext('f()'); -assert.equal(100, foo); +assert.equal(100, global.foo); diff --git a/tools/doc/json.js b/tools/doc/json.js index 299c8ed9fd8..b2165c15d23 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -183,7 +183,7 @@ function processList(section) { list.forEach(function(tok) { var type = tok.type; if (type === 'space') return; - if (type === 'list_item_start') { + if (type === 'list_item_start' || type === 'loose_item_start') { var n = {}; if (!current) { values.push(n); @@ -260,6 +260,14 @@ function processList(section) { // event: each item is an argument. section.params = values; break; + + default: + if (section.list.length > 0) { + section.desc = section.desc || []; + for (var i = 0; i < section.list.length; i++) { + section.desc.push(section.list[i]); + } + } } // section.listParsed = values; diff --git a/tools/test.py b/tools/test.py index 13cc8db1d35..2d596e522de 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1515,10 +1515,15 @@ def Main(): if not exists(vm): print "Can't find shell executable: '%s'" % vm continue + archEngineContext = Execute([vm, "-p", "process.arch"], context) + vmArch = archEngineContext.stdout.rstrip() + if archEngineContext.exit_code is not 0 or vmArch == "undefined": + print "Can't determine the arch of: '%s'" % vm + continue env = { 'mode': mode, 'system': utils.GuessOS(), - 'arch': arch, + 'arch': vmArch, } test_list = root.ListTests([], path, context, arch, mode) unclassified_tests += test_list diff --git a/vcbuild.bat b/vcbuild.bat index cd3f758a393..4910ce3db88 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -35,6 +35,7 @@ set download_arg= set release_urls_arg= set build_release= set configure_flags= +set build_addons= :next-arg if "%1"=="" goto args-done @@ -53,8 +54,9 @@ if /i "%1"=="nosnapshot" set nosnapshot=1&goto arg-ok if /i "%1"=="noetw" set noetw=1&goto arg-ok if /i "%1"=="noperfctr" set noperfctr=1&goto arg-ok if /i "%1"=="licensertf" set licensertf=1&goto arg-ok -if /i "%1"=="test" set test_args=%test_args% sequential parallel message -J&set jslint=1&goto arg-ok -if /i "%1"=="test-ci" set test_args=%test_args% %test_ci_args% -p tap --logfile test.tap message sequential parallel&goto arg-ok +if /i "%1"=="test" set test_args=%test_args% addons sequential parallel message -J&set jslint=1&set build_addons=1&goto arg-ok +if /i "%1"=="test-ci" set test_args=%test_args% %test_ci_args% -p tap --logfile test.tap addons message sequential parallel&set build_addons=1&goto arg-ok +if /i "%1"=="test-addons" set test_args=%test_args% addons&set build_addons=1&goto arg-ok if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok if /i "%1"=="test-gc" set test_args=%test_args% gc&set buildnodeweak=1&goto arg-ok @@ -89,6 +91,9 @@ if defined build_release ( set i18n_arg=small-icu ) +:: assign path to node_exe +set "node_exe=%config%\node.exe" + if "%config%"=="Debug" set configure_flags=%configure_flags% --debug if defined nosnapshot set configure_flags=%configure_flags% --without-snapshot if defined noetw set configure_flags=%configure_flags% --without-etw& set noetw_msi_arg=/p:NoETW=1 @@ -237,15 +242,36 @@ ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/no :build-node-weak @rem Build node-weak if required -if "%buildnodeweak%"=="" goto run-tests +if "%buildnodeweak%"=="" goto build-addons "%config%\node" deps\npm\node_modules\node-gyp\bin\node-gyp rebuild --directory="%~dp0test\gc\node_modules\weak" --nodedir="%~dp0." if errorlevel 1 goto build-node-weak-failed -goto run-tests +goto build-addons :build-node-weak-failed echo Failed to build node-weak. goto exit +:build-addons +if not defined build_addons goto run-tests +if not exist "%node_exe%" ( + echo Failed to find node.exe + goto run-tests +) +echo Building add-ons +:: clear +for /d %%F in (test\addons\??_*) do ( + rd /s /q %%F +) +:: generate +"%node_exe%" tools\doc\addon-verify.js +:: building addons +for /d %%F in (test\addons\*) do ( + "%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp rebuild ^ + --directory="%%F" ^ + --nodedir="%cd%" +) +goto run-tests + :run-tests if "%test_args%"=="" goto jslint if "%config%"=="Debug" set test_args=--mode=debug %test_args%