Commit Graph

254 Commits

Author SHA1 Message Date
Luigi Pinca
b533fb3508 tools: enable no-else-return lint rule
Refs: https://github.com/nodejs/node/pull/32644
Refs: https://github.com/nodejs/node/pull/32662

PR-URL: https://github.com/nodejs/node/pull/32667
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-05-16 06:42:16 +02:00
Stephen Belanger
13c5a1629c
async_hooks: move PromiseHook handler to JS
This avoids the need to wrap every promise in an AsyncWrap and also
makes it easier to skip the machinery to track destroy events when
there's no destroy listener.

Co-authored-by: Andrey Pechkurov <apechkurov@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/32891
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2020-05-09 07:52:22 +02:00
Anna Henningsen
8698dd98bb
test: fix out-of-bound reads from invalid sizeof usage
`sizeof(data)` does not return the correct result here, as it measures
the size of the `data` variable, not what it points to.

PR-URL: https://github.com/nodejs/node/pull/33115
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-30 04:56:11 +02:00
Xu Meng
b61488fe24
test: only detect uname on supported os
To skip some tests on IBMi PASE, we use
uname to detect the true os name, but
on Windows machines there is no uname
available.

PR-URL: https://github.com/nodejs/node/pull/32833
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-16 08:58:37 +05:30
Xu Meng
b416993c4f
test: skip some binding tests on IBMi PASE
IBMi PASE Node.js always links to shared openssl
and zlib libraries. So skip the static binding tests.

PR-URL: https://github.com/nodejs/node/pull/31967
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2020-03-30 10:19:48 +02:00
cjihrig
9d1a3b6f60
doc,lib,src,test: make --experimental-report a nop
This commit makes the --experimental-report CLI flag a no-op.

PR-URL: https://github.com/nodejs/node/pull/32242
Fixes: https://github.com/nodejs/node/issues/26293
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-03-15 13:29:34 -04:00
Ben Noordhuis
cc0748f509 test: export public symbols in addons tests
Upcoming changes to node-gyp will turn on `-fvisibility=hidden` on
macOS. Ensure that public symbols that are dlsym'd have default
visibility.

Refs: https://github.com/nodejs/node/pull/28647
Refs: https://github.com/nodejs/node-gyp/pull/1828

PR-URL: https://github.com/nodejs/node/pull/28717
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-01-17 18:51:50 -08:00
Thang Tran
783f8c626c test: change buffer offset to accommodate V8 BackingStore
To avoid problem with the behavior of new V8 BackingStore API,
change the offset. The base address of each test case will be
different.

Fixes: https://github.com/nodejs/node/issues/31061

PR-URL: https://github.com/nodejs/node/pull/31171
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-05 18:21:15 -08:00
Ruben Bridgewater
e038d6a1cd
test: refactor common.expectsError
This completely refactors the `expectsError` behavior: so far it's
almost identical to `assert.throws(fn, object)` in case it was used
with a function as first argument. It had a magical property check
that allowed to verify a functions `type` in case `type` was passed
used in the validation object. This pattern is now completely removed
and `assert.throws()` should be used instead.

The main intent for `common.expectsError()` is to verify error cases
for callback based APIs. This is now more flexible by accepting all
validation possibilites that `assert.throws()` accepts as well. No
magical properties exist anymore. This reduces surprising behavior
for developers who are not used to the Node.js core code base.

This has the side effect that `common` is used significantly less
frequent.

PR-URL: https://github.com/nodejs/node/pull/31092
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-12-31 15:54:20 +01:00
Anna Henningsen
bbca4a8a3d
src,test: use v8::Global instead of v8::Persistent
This is in preparation for a lint rule forbidding usage of
`v8::Persistent`.

PR-URL: https://github.com/nodejs/node/pull/31018
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2019-12-24 14:31:28 +01:00
Thang Tran
4f523c2c1a
src: migrate to new V8 ArrayBuffer API
ArrayBuffer without BackingStore will soon be deprecated.

Fixes:https://github.com/nodejs/node/issues/30529

PR-URL: https://github.com/nodejs/node/pull/30782
Fixes: https://github.com/nodejs/node/issues/30529
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-12 10:05:44 -05:00
Richard Lau
d4e00ec0ae
test: mark addons/openssl-bindings/test flaky on arm
PR-URL: https://github.com/nodejs/node/pull/30838
Refs: https://github.com/nodejs/node/issues/30786
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-12-07 16:07:44 -05:00
garygsc
79faa87502
test: use arrow functions in addons tests
Convert all anonymous callback functions in `test/addons/**/*.js`
to use arrow functions, except for those in
`test/addons/make-callback/test.js` (which reference `this`)

`writing-tests.md` states to use arrow functions when appropriate.

PR-URL: https://github.com/nodejs/node/pull/30131
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-11-30 18:08:59 +01:00
Anna Henningsen
b7ef593744
buffer: release buffers with free callbacks on env exit
Invoke the free callback for a given `Buffer` if it was created
with one, and mark the underlying `ArrayBuffer` as detached.

This makes sure that the memory is released e.g. when addons inside
Workers create such `Buffer`s.

PR-URL: https://github.com/nodejs/node/pull/30551
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-11-30 02:02:50 +01:00
Jeremy Apthorp
4f434187ff
src: add file name to 'Module did not self-register' error
PR-URL: https://github.com/nodejs/node/pull/30125
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-11-19 16:03:55 +01:00
Anna Henningsen
6cb8e4b12c
src: mark ArrayBuffers with free callbacks as untransferable
More precisely, make them untransferable if they were created through
*our* APIs, because those do not follow the improved free callback
mechanism that V8 uses now. All other ArrayBuffers can be transferred
between threads now, the assumption being that they were created in a
clean way that follows the V8 API on this.

This addresses a TODO comment.

Refs: https://github.com/nodejs/node/pull/30339#issuecomment-552225353

PR-URL: https://github.com/nodejs/node/pull/30475
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2019-11-19 14:01:32 +01:00
Anna Henningsen
e66a2acc4c src: migrate off ArrayBuffer::GetContents
V8 deprecates `GetContents()` in favour of `GetBackingStore()`.
Update our code to reflect that.
V8 also deprecates `Externalize()` and `IsExternal()`; we should
be able to remove all usage of this once V8 8.0 is there.

PR-URL: https://github.com/nodejs/node/pull/30339
Refs: bfe3d6bce7
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2019-11-12 06:29:23 +01:00
Anna Henningsen
55f4db183f test: remove AtExit() addon test
Move the one bit of the addon test that was not covered by the
cctest into the latter and delete the former.

Refs: https://github.com/nodejs/node/pull/30227#discussion_r341879242

PR-URL: https://github.com/nodejs/node/pull/30275
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-11-07 19:53:40 -08:00
Anna Henningsen
5b2067c6ca
src: deprecate two- and one-argument AtExit()
Using `AtExit()` without an `Environment*` pointer or providing
an argument is almost always a sign of improperly relying on global
state and/or using `AtExit()` as an addon when the addon-targeting
`AddEnvironmentCleanupHook()` would be the better choice.

Deprecate those variants. This also updates the addon docs to
refer to `AddEnvironmentCleanupHook()` rather than `AtExit()`.

PR-URL: https://github.com/nodejs/node/pull/30227
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-05 23:59:02 +01:00
mpark86
175c318bc1 test: use arrow functions for callbacks
Use arrow functions for callbacks in
test/addons/make-callback-recurse/test.js.

PR-URL: https://github.com/nodejs/node/pull/30069
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2019-10-25 13:29:50 -07:00
Sam Roberts
51c097b2a8 test: debug output for dlopen-ping-pong test
Make test failures easier to diagnose through progress logging, and
reporting of dlerror().

PR-URL: https://github.com/nodejs/node/pull/29818
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-10-09 11:54:59 -07:00
cjihrig
663ef98e9a
test: simplify force-context-aware test
PR-URL: https://github.com/nodejs/node/pull/29705
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-09-29 08:42:08 -04:00
Anton Gerasimov
c2ce8d0547 tls: add option for private keys for OpenSSL engines
Add `privateKeyIdentifier` and `privateKeyEngine` options
to get private key from an OpenSSL engine in tls.createSecureContext().

PR-URL: https://github.com/nodejs/node/pull/28973
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-09-27 15:50:56 -07:00
Shelley Vohr
f120e6d817 test: --force-context-aware cli flag
PR-URL: https://github.com/nodejs/node/pull/29631
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-09-24 22:49:35 -07:00
Rainer Poisel
71b5ce5885 test: make exported method static
The exported method can be static as it will never be called directly.

PR-URL: https://github.com/nodejs/node/pull/29102
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-15 22:58:40 -07:00
João Reis
8ef68e66d0 test: clean tmpdir on process exit
PR-URL: https://github.com/nodejs/node/pull/28858
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-08-10 19:22:11 -07:00
Sam Roberts
41fa5536d1 test: specialize OOM check for AIX
Assumption that if memory can be malloc()ed it can be used is not true
on AIX. Later access of the allocated pages can trigger SIGKILL if there
are insufficient VM pages.

Use psdanger() to better estimate available memory.

Fixes: https://github.com/nodejs/build/issues/1849

More info:
- https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/generalprogramming/sys_mem_alloc.html
- https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/p_bostechref/psdanger.html

Related to:
- https://github.com/nodejs/build/issues/1820#issuecomment-505998851
- https://github.com/nodejs/node/pull/28469
- https://github.com/nodejs/node/pull/28516

PR-URL: https://github.com/nodejs/node/pull/28857
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-27 16:03:43 -07:00
Christopher Hiller
bff7a46f31
report: modify getReport() to return an Object
It's likely that anyone using `process.report.getReport()` will be
processing the return value thereafter (e.g., filtering fields or
redacting secrets). This change eliminates boilerplate by calling
`JSON.parse()` on the return value.

Also modified the `validateContent()` and `validate()` test helpers in
`test/common/report.js` to be somewhat more obvious and helpful. Of
note, a report failing validation will now be easier (though still not
_easy_) to read when prepended to the stack trace.

- Refs: https://github.com/nodejs/diagnostics/issues/315

PR-URL: https://github.com/nodejs/node/pull/28630
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-12 14:48:09 -07:00
Sam Roberts
1245aca41c test: skip stringbytes-external-exceed-max on AIX
Add SKIP status for more tests in stringbytes-external-exceed-max that
are failing on AIX.

PR-URL: https://github.com/nodejs/node/pull/28516
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-07-04 13:03:58 -07:00
Sam Roberts
3c9c89df12 test: skip tests related to CI failures on AIX
These tests seem to trigger failures in the entire CI job (not just the
test) on AIX. Skip them to see if that helps alleviate spurious failures
in node-test-commit-aix (and the upstream PR and commit test jobs).

See:
- https://github.com/nodejs/build/issues/1820#issuecomment-505998851
- https://github.com/nodejs/build/issues/1847#issuecomment-504210708

PR-URL: https://github.com/nodejs/node/pull/28469
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-02 06:41:30 +02:00
Anna Henningsen
039cfdc838
test: add addon tests for RegisterSignalHandler()
Ensure coverage for the different combinations of arguments.

PR-URL: https://github.com/nodejs/node/pull/27775
Refs: https://github.com/nodejs/node/pull/27246
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-14 19:11:42 +02:00
Anna Henningsen
b31bfaddeb test: make sure vtable is generated in addon test with LTO
PR-URL: https://github.com/nodejs/node/pull/28057
Fixes: https://github.com/nodejs/node/issues/28026
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-06-07 05:20:40 +02:00
Boxuan Li
c903c99d4b test: add mustCall to openssl-client-cert-engine
PR-URL: https://github.com/nodejs/node/pull/27474
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-03 06:22:30 +02:00
Masashi Hirano
fb3f6005c0 test: fix ineffective error tests
Fix tests whether errors are thrown correctly
because they are successful when error doesn't get thrown.

PR-URL: https://github.com/nodejs/node/pull/27333
Fixes: https://github.com/nodejs/node/issues/26385
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-24 10:07:09 +02:00
guybedford
b1094dbe19
esm: phase two of new esm implementation
This PR updates the current `--experimental-modules` implementation
based on the work of the modules team  and reflects Phase 2 of our
new modules plan.

The largest differences from the current implementation include

* `packge.type` which can be either `module` or `commonjs`
  - `type: "commonjs"`:
    - `.js` is parsed as commonjs
    - default for entry point without an extension is commonjs
  - `type: "module"`:
    - `.js` is parsed as esm
    - does not support loading JSON or Native Module by default
    - default for entry point without an extension is esm
* `--entry-type=[mode]`
  - allows you set the type on entry point.
* A new file extension `.cjs`.
  - this is specifically to support importing commonjs in the
    `module` mode.
  - this is only in the esm loader, the commonjs loader remains
    untouched, but the extension will work in the old loader if you use
    the full file path.
* `--es-module-specifier-resolution=[type]`
  - options are `explicit` (default) and `node`
  - by default our loader will not allow for optional extensions in
    the import, the path for a module must include the extension if
    there is one
  - by default our loader will not allow for importing directories that
    have an index file
  - developers can use `--es-module-specifier-resolution=node` to
    enable the commonjs specifier resolution algorithm
  - This is not a “feature” but rather an implementation for
    experimentation. It is expected to change before the flag is
    removed
* `--experimental-json-loader`
  - the only way to import json when `"type": "module"`
  - when enable all `import 'thing.json'` will go through the
    experimental loader independent of mode
  - based on https://github.com/whatwg/html/issues/4315
* You can use `package.main` to set an entry point for a module
  - the file extensions used in main will be resolved based on the
    `type` of the module

Refs: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md
Refs: https://github.com/GeoffreyBooth/node-import-file-specifier-resolution-proposal
Refs: https://github.com/nodejs/modules/pull/180
Refs: https://github.com/nodejs/ecmascript-modules/pull/6
Refs: https://github.com/nodejs/ecmascript-modules/pull/12
Refs: https://github.com/nodejs/ecmascript-modules/pull/28
Refs: https://github.com/nodejs/modules/issues/255
Refs: https://github.com/whatwg/html/issues/4315
Refs: https://github.com/w3c/webcomponents/issues/770
Co-authored-by: Myles Borins <MylesBorins@google.com>
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
Co-authored-by: Evan Plaice <evanplaice@gmail.com>
Co-authored-by: Geoffrey Booth <webmaster@geoffreybooth.com>
Co-authored-by: Michaël Zasso <targos@protonmail.com>

PR-URL: https://github.com/nodejs/node/pull/26745
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2019-03-27 15:52:11 -04:00
Ruben Bridgewater
b08a867d60
benchmark,doc,lib: capitalize more comments
PR-URL: https://github.com/nodejs/node/pull/26849
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-03-27 17:20:06 +01:00
Ruben Bridgewater
9edce1e12a
benchmark,doc,lib,test: capitalize comments
This updates a lot of comments.

PR-URL: https://github.com/nodejs/node/pull/26223
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-02-28 18:31:10 +01:00
Anna Henningsen
8ebd339031
worker: improve integration with native addons
Allow loading add-ons from multiple Node.js instances if they are
declared context-aware; in particular, this applies to N-API addons.

Also, plug a memory leak that occurred when registering N-API addons.

Refs: https://github.com/nodejs/node/pull/23319

PR-URL: https://github.com/nodejs/node/pull/26175
Fixes: https://github.com/nodejs/node/issues/21481
Fixes: https://github.com/nodejs/node/issues/21783
Fixes: https://github.com/nodejs/node/issues/25662
Fixes: https://github.com/nodejs/node/issues/20239
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-02-22 21:42:09 +01:00
Daniel Bevenius
611043cc66
test: silence compiler warning in openssl-binding
Currently, this test generated the following compiler warning:
../binding.cc:33:30: warning:
'TLSv1_2_server_method' is deprecated [-Wdeprecated-declarations]
  const SSL_METHOD* method = TLSv1_2_server_method();
                             ^
/node/deps/openssl/openssl/include/openssl/ssl.h:1877:1:
note: 'TLSv1_2_server_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void))
^
1 warning generated.

This commit adds -Wno-deprecated-declarations to silence this warning
for this test.

PR-URL: https://github.com/nodejs/node/pull/26067
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2019-02-16 00:19:10 +01:00
Pushkal B
1833782bb1
test: replaced anonymous fn with arrow syntax
PR-URL: https://github.com/nodejs/node/pull/26029
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-14 00:06:05 +01:00
Richard Lau
fcaeb1f122 build: export deprecated OpenSSL symbols on Windows
Methods such as `TLSv1_server_method` are categorized as
`DEPRECATEDIN_1_1_0`. Add the deprecated categories to
the list of categories to include passed to `mkssldef.py`.

Adds a regression test to `test/addons/openssl-binding`.

PR-URL: https://github.com/nodejs/node/pull/25991
Refs: https://github.com/nodejs/node/issues/20369
Refs: https://github.com/nodejs/node/issues/25981
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-11 07:28:01 +01:00
Daniel Bevenius
f4510c4148 test, tools: suppress addon function cast warnings
Currently, there are a number of compiler warnings generated when
building the addons on Linux, for example:

make[1]: Entering directory '/node/test/addons/zlib-binding/build'
  CXX(target) Release/obj.target/binding/binding.o
  SOLINK_MODULE(target) Release/obj.target/binding.node
  COPY Release/binding.node
make[1]: Leaving directory '/node/test/addons/zlib-binding/build'
In file included from ../binding.cc:1:
/node/src/node.h:515:51: warning:
cast between incompatible function types from
'void (*)(v8::Local<v8::Object>,
          v8::Local<v8::Value>,
          v8::Local<v8::Context>)' to
'node::addon_context_register_func' {aka
'void (*)(v8::Local<v8::Object>,
          v8::Local<v8::Value>,
          v8::Local<v8::Context>,
          void*)'} [-Wcast-function-type]
(node::addon_context_register_func) (regfunc), \
					   ^
/node/src/node.h:533:3:
note: in expansion of macro 'NODE_MODULE_CONTEXT_AWARE_X'
   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../binding.cc:58:1:
note: in expansion of macro 'NODE_MODULE_CONTEXT_AWARE'
 NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, Initialize)
 ^~~~~~~~~~~~~~~~~~~~~~~~~

This commit adds the flag -Wno-cast-function-type to suppress these
warnings. With this change the warnings are not displayed anymore and
the output matches that of osx when running
'make -j8 test/addons/.buildstamp'.

PR-URL: https://github.com/nodejs/node/pull/25663
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-02-01 14:08:20 +01:00
Anna Henningsen
ef1c639db5 src: restrict unloading addons to Worker threads
Unloading native addons from the main thread was an (presumably
unintended) significant breaking change, because addons may
rely on their memory being available after an `Environment` exits.

This patch only restricts this to Worker threads, at least for the
time being, and thus matches the behaviour from
https://github.com/nodejs/node/pull/23319.

PR-URL: https://github.com/nodejs/node/pull/25577
Refs: https://github.com/nodejs/node/pull/24861
Refs: https://github.com/nodejs/node/pull/23319
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-23 05:35:46 +01:00
Anna Henningsen
63d4cae009
worker: remove --experimental-worker flag
Having an experimental feature behind a flag makes change
if we are expecting significant breaking changes to its API.

Since the Worker API has been essentially stable since
its initial introduction, and no noticeable doubt about
possibly not keeping the feature around has been voiced,
removing the flag and thereby reducing the barrier to experimentation,
and consequently receiving feedback on the implementation,
seems like a good idea.

PR-URL: https://github.com/nodejs/node/pull/25361
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-01-09 00:31:33 +01:00
Rich Trott
7d453ff212 test: replace internals with public API
Remove instances where `--expose-internals` is used to gain access to
buffer.kStringMaxLength. The property is availalble without a flag. It
is undocumented but the same as the documented
`buffer.constants.MAX_STRING_LENGTH` so use that. (We even have a test
that confirms that they are the same value.)

PR-URL: https://github.com/nodejs/node/pull/25309
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-03 22:58:26 -08:00
Gabriel Schulhof
13abc6adfb src: unload addons when environment quits
This is an alternative to https://github.com/nodejs/node/pull/23319
which attaches the loaded addons to the environment and closes them
when the environment is destroyed.

PR-URL: https://github.com/nodejs/node/pull/24861
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-12-19 18:35:38 -08:00
Anna Henningsen
622e348d8f test,doc: add tests and docs for addon unloading
Originally from portions of https://github.com/nodejs/node/pull/23319/.

PR-URL: https://github.com/nodejs/node/pull/24861
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-12-19 18:34:28 -08:00
Anna Henningsen
fcd7a72428
async_hooks: add HandleScopes to C++ embedder/addon API
Add `HandleScope`s to the public C++ API for embedders/addons,
since these methods create V8 handles that should not leak into
the outer scopes.

In particular, for some of the methods it was not clear from
the function signatures that these functions previously
needed to be invoked with a `HandleScope`.

PR-URL: https://github.com/nodejs/node/pull/24285
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-11-13 15:25:46 +01:00
Daniel Bevenius
faa584ab22 test: fix v8 Set/Get compiler warnings
PR-URL: https://github.com/nodejs/node/pull/24246
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-11 08:02:30 +01:00
Daniel Bevenius
d58a0c6285 test: fix NewFromUtf8 compiler warning
Currently there are a number of compiler warnings like the following:

../binding.cc:6:41:
warning: 'NewFromUtf8' is deprecated:
Use maybe version [-Wdeprecated-declarations]
  args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
                                        ^
/node/deps/v8/include/v8.h:2883:10:
note: 'NewFromUtf8' has been explicitly marked deprecated here
  static V8_DEPRECATE_SOON(
         ^
/node/deps/v8/include/v8config.h:341:29:
note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^

This commit updates the code to use the maybe versions.

PR-URL: https://github.com/nodejs/node/pull/24216
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-09 21:26:31 -08:00
Anna Henningsen
9c7d19104d buffer: throw exception when creating from non-Node.js Context
Throw an exception instead of crashing when attempting to create
`Buffer` objects from a Context that is not associated with
a Node.js `Environment`.

Possible alternatives for the future might be just returning
a plain `Uint8Array`, or working on providing `Buffer` for all
`Context`s.

PR-URL: https://github.com/nodejs/node/pull/23938
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-11-03 23:31:03 -07:00
Anna Henningsen
a3cad3e2ff
test: verify performance.timerify() works w/ non-Node Contexts
PR-URL: https://github.com/nodejs/node/pull/23784
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-10-25 19:49:46 +02:00
Weijia Wang
ac23e6557f buffer: move process.binding('buffer') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/22370
Refs: https://github.com/nodejs/node/issues/22160
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-10-15 19:01:20 +08:00
ashleysimpson
190d146b78
test: inline common module boolean
PR-URL: https://github.com/nodejs/node/pull/23479
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-14 22:10:40 +02:00
Tim Cheung
7f74515cd1
test: flip assertion arguments for make-callback/test.js
Assertion arguments should have the first value be the actual value,
while the second value be the expected value.

PR-URL: https://github.com/nodejs/node/pull/23470
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-13 19:34:40 -07:00
Andreas Haas
7dde560beb src: replace deprecated uses of FunctionTemplate::GetFunction
PR-URL: https://github.com/nodejs/node/pull/22993
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-09-24 05:44:28 +02:00
Michaël Zasso
8518548a79
test: remove usage of deprecated V8 APIs in addons
PR-URL: https://github.com/nodejs/node/pull/22704
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-09-07 15:47:48 +02:00
Anna Henningsen
4a5886cb8a test: fix flaky addons/callback-scope/test-resolve-async
Fixes: https://github.com/nodejs/node/issues/22668
PR-URL: https://github.com/nodejs/node/pull/22664
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-09-07 09:52:18 +02:00
Refael Ackermann
4ce744a24b test: call gc() explicitly to avoid OOM
PR-URL: https://github.com/nodejs/node/pull/22301
Refs: https://github.com/nodejs/reliability/issues/12
Refs: https://github.com/nodejs/node/issues/16354
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2018-08-14 02:27:32 -04:00
Michaël Zasso
df08779e0d
test: make crashOnUnhandleRejection opt-out
This commit removes `common.crashOnUnhandledRejection()` and adds
`common.disableCrashOnUnhandledRejection()`.

To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for the rare cases where it's needed.

PR-URL: https://github.com/nodejs/node/pull/21849
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-07-19 08:47:28 +02:00
Gabriel Schulhof
602da6492f src: add context-aware init macro and doc
Introduces macros `NODE_MODULE_INITIALIZER` which expands to the name
of the special symbol that process.dlopen() will look for to initialize
an addon, and `NODE_MODULE_INIT()` which creates the boilerplate for
a context-aware module which can be loaded multiple times via the
special symbol mechanism.

Additionally, provides an example of using the new macro to construct
an addon which stores per-addon-instance data in a heap-allocated
structure that gets passed to each binding, rather than in a collection
of global static variables.

Re: https://github.com/nodejs/node/issues/21291#issuecomment-396729727
PR-URL: https://github.com/nodejs/node/pull/21318
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
2018-07-03 18:34:50 -04:00
Anatoli Papirovski
2930bd1317
src: refactor timers to remove TimerWrap
Refactor Timers to behave more similarly to Immediates by having
a single uv_timer_t handle which is stored on the Environment.

No longer expose timers in a public binding and instead make
it part of the internalBinding.

PR-URL: https://github.com/nodejs/node/pull/20894
Fixes: https://github.com/nodejs/node/issues/10154
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2018-06-24 21:35:05 -07:00
Anna Henningsen
aa2304b8d5
worker,src: display remaining handles if uv_loop_close fails
Right now, we crash the process if there are handles remaining
on the event loop when we exit (except for the main thread).

This does not provide a lot of information about causes, though;
in particular, we don’t show which handles are pending and
who own them.

This patch adds debug output to these cases to help with the
situation.

PR-URL: https://github.com/nodejs/node/pull/21238
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-06-13 12:23:36 +02:00
Anna Henningsen
00f395db45
src: make AsyncResource destructor virtual
`AsyncResource` is intended to be a base class, and since we don’t
know what API consumers will do with it in their own code,
it’s good practice to make its destructor virtual.

This should not be ABI-breaking since all class methods are inline.

PR-URL: https://github.com/nodejs/node/pull/20633
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-05-14 18:18:16 +02:00
Gabriel Schulhof
c1078c4a3b src: cover extra load-via-special-symbol scenario
We need to look for a special symbol even if the module self-registers
when the module self-registers with the wrong version.

PR-URL: https://github.com/nodejs/node/pull/20186
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-04-23 08:59:03 -04:00
Daniel Bevenius
bd0a690632 test: fix warning in dlopen-ping-pong/binding.cc
Currently, the following compiler warning is issued:
../binding.cc:26:27:
warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  const String::Utf8Value filename(args[0]);
                          ^

This commit updates the code to use the Isolate version.

PR-URL: https://github.com/nodejs/node/pull/19966
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-14 13:22:31 +02:00
Joyee Cheung
362694401f
src: rename ERR_STRING_TOO_LARGE to ERR_STRING_TOO_LONG
The old error name and message were trying to be consistent with
ERR_BUFFER_TOO_LARGE but they were not really accurate.
The kStringMaxLength was measured in number of characters,
not number of bytes. The name ERR_STRING_TOO_LARGE also
seems a bit awkward. This patch tries to correct them before
they get released to users.

PR-URL: https://github.com/nodejs/node/pull/19864
Refs: https://github.com/nodejs/node/pull/19739
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-04-10 01:08:10 +02:00
Gabriel Schulhof
244af7a9d5 test: verify multiple init via well-known symbol
Re-`require()` the addon after clearing its cache to ensure that it is
re-initialized via the well-known symbol.

PR-URL: https://github.com/nodejs/node/pull/19875
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-04-08 21:21:07 -04:00
Joyee Cheung
63eb267c34
src: migrate string_bytes.cc to throw errors with code
PR-URL: https://github.com/nodejs/node/pull/19739
Fixes: https://github.com/nodejs/node/issues/3175
Fixes: https://github.com/nodejs/node/issues/9489
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-04-07 17:15:13 +08:00
Daniel Bevenius
695590e386 test: fix compiler warnings in callback-scope
Currently there are two compiler warnings generated from the addons test
callback-scope:

../binding.cc:44:10:
warning: 'Resolve' is deprecated [-Wdeprecated-declarations]
  local->Resolve(v8::Undefined(isolate));
         ^
../../../../deps/v8/include/v8.h:3893:45:
note: 'Resolve' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", void Resolve(Local<Value> value));
         ^

../binding.cc:52:54:
warning: 'New' is deprecated [-Wdeprecated-declarations]
    persistent.Reset(isolate, v8::Promise::Resolver::New(isolate));
                                                     ^
../../../../deps/v8/include/v8.h:3880:42:
note: 'New' has been explicitly marked deprecated here
Local<Resolver> New(Isolate* isolate));

This commit updates the test to use non-deprecated functions.

PR-URL: https://github.com/nodejs/node/pull/19252
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-03-11 16:13:39 +01:00
Kyle Farnung
148f402320 test: specify 'dir' for directory symlinks
Directory symlinks in Windows require the 'dir' flag to be passed to
create the symlink correctly.

PR-URL: https://github.com/nodejs/node/pull/19049
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-03-01 15:47:29 -08:00
Ben Noordhuis
3828fc6289 src: make process.dlopen() load well-known symbol
Look for symbol `node_register_module_v${NODE_MODULE_VERSION}` if the
add-on didn't self-register.  This can be used to create add-ons that
support multiple Node.js versions from a single shared object.

PR-URL: https://github.com/nodejs/node/pull/18934
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matheus Marchini <matheus@sthima.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-01 13:45:57 +01:00
Daniel Bevenius
53a5d87bec test: fix deprecation warning in binding.cc
Currently, the make-callback-domain-warning addon generates the
following warning:
../binding.cc:22:9:
warning: 'MakeCallback' is deprecated: Use MakeCallback(...,
      async_context) [-Wdeprecated-declarations]
  node::MakeCallback(isolate, recv, method, 0, nullptr);
        ^
../../../../src/node.h:172:50:
note: 'MakeCallback' has been explicitly marked
      deprecated here
                NODE_EXTERN v8::Local<v8::Value> MakeCallback(
                                                 ^
1 warning generated.

This commit fixes this warning.

PR-URL: https://github.com/nodejs/node/pull/18877
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-02-22 06:25:58 +01:00
Gus Caplan
6934792eb3 lint: move eslint to new plugin system
PR-URL: https://github.com/nodejs/node/pull/18566
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2018-02-20 13:13:22 -06:00
Ali Ijaz Sheikh
6ab288f3b8 test: fix warnings in addon tests
The legacy MakeCallback deprecation was resulting in compile time
warnings in adddon tests. Fix them.

Ref: https://github.com/nodejs/node/pull/18632

PR-URL: https://github.com/nodejs/node/pull/18810
Refs: https://github.com/nodejs/node/pull/18632
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-02-16 15:47:07 -08:00
Ruben Bridgewater
644fdd60d4
test: minor refactoring
Add punctuation and comments about code that should not throw.
Also remove a obsolete test and refactor some tests.

PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-02-16 16:54:07 +01:00
Ruben Bridgewater
caee112e52
test: remove assert.doesNotThrow()
There is actually no reason to use `assert.doesNotThrow()` in the
tests. If a test throws, just let the error bubble up right away
instead of first catching it and then rethrowing it.

PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-02-16 16:53:47 +01:00
Andreas Madsen
14bc3e22f3
domain: runtime deprecate MakeCallback
Users of MakeCallback that adds the domain property to carry context,
should start using the async_context variant of MakeCallback or the
AsyncResource class.

PR-URL: https://github.com/nodejs/node/pull/17417
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-09 10:38:50 +01:00
Michael Dawson
fe442f6b5f test: properly tag anonymous namespaces
For tests that use anonymous namespaces, some tagged the close
of the namespace with 'namespace' while others used
'anonymous namespace'. It was suggested I should use
'anonymous namespace' in a recent PR review so make all of the
tests consistent with this.

PR-URL: https://github.com/nodejs/node/pull/18583
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-02-08 18:43:36 -05:00
Daniel Bevenius
ac7f1e339c
build: make gyp user defined variables lowercase
I mistakenly introduced user defined variables using uppercase
characters, reading the gyp documentation they state:
"Predefined variables. By convention, these are named with
CAPITAL_LETTERS. Predefined variables are set automatically by GYP"
and also "By convention, user-defined variables are named with
lowercase_letters."

This commit renames the user defined variables to lowercase to follow
the above mentioned convention.

PR-URL: https://github.com/nodejs/node/pull/16238
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-01 09:51:16 +01:00
Rich Trott
bf6ce47259 test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir).

PR-URL: https://github.com/nodejs/node/pull/17856
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-01-31 22:11:07 -08:00
Anatoli Papirovski
eeede3b19c
domain: further abstract usage in C++
Move the majority of C++ domain-related code into JS land by introducing
a top level domain callback which handles entering & exiting the domain.

Move the rest of the domain necessities into their own file that creates
an internal binding, to avoid exposing domain-related code on the
process object.

Modify an existing test slightly to better test domain-related code.

PR-URL: https://github.com/nodejs/node/pull/18291
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-01-29 11:37:29 -05:00
Rod Vagg
57bd27eda8 Revert "build,test: make building addon tests less fragile"
This reverts commit d9b59def72.

Breaks downloadable source tarball builds as we remove some files prior
to creating a tarball but those files are included in the comprehensive
list of dependencies listed in .deps.

Ref: https://github.com/nodejs/node/pull/17407
PR-URL: https://github.com/nodejs/node/pull/18287
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-01-25 08:18:24 +11:00
Ben Noordhuis
d9b59def72
build,test: make building addon tests less fragile
* Get rid of recursive `make` when building the node binary.  An earlier
  commit makes GYP write out rules that we can use for proper dependency
  tracking.

* Use module name 'binding' in addons.md and addons-napi/*/binding.gyp.
  This massively simplifies the logic for generating the build rules.

* Check in auto-generated add-on tests from `doc/api/addons.md`.  The
  files change rarely and generating them dynamically causes no end of
  race conditions and special-casing during the build.

PR-URL: https://github.com/nodejs/node/pull/17407
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-01-21 02:19:46 +01:00
Yihong Wang
f878f9414e
build: refine static and shared lib build
Refine the static and shared lib build process in order
to integrate static and shared lib verfication into CI.
When building both static and shared lib, we still build
node executable now and it uses the shared and static lib.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>

Fixes: https://github.com/nodejs/node/issues/14158
PR-URL: https://github.com/nodejs/node/pull/17604
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-01-17 11:34:28 +08:00
Sho Miyamoto
c84582cbb6
test: add common.crashOnUnhandledRejection to addons/callback-scope
PR-URL: https://github.com/nodejs/node/pull/18076
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-01-13 14:50:30 -08:00
Anatoli Papirovski
d72c78b19c
test: fix flaky test-resolve-async
PR-URL: https://github.com/nodejs/node/pull/17957
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-01-05 01:08:03 +01:00
Rich Trott
ba9801a8d2 test: remove unnecessary use of common.PORT in addons test
Using port 0 to request an open port from the operating system is
sufficient in openssl-client-cert-engine/test.js.

PR-URL: https://github.com/nodejs/node/pull/17563
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-12-11 19:52:23 -08:00
IHsuan
694e7baf00
test: add common.crashOnUnhandledRejection()
PR-URL: https://github.com/nodejs/node/pull/17247
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-06 13:56:52 -05:00
Daniel Bevenius
e32bbbf4d7 src: use nullptr instead of NULL
PR-URL: https://github.com/nodejs/node/pull/17373
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-12-01 07:45:00 +01:00
Anna Henningsen
c0f3bc24de
src: add helper for addons to get the event loop
Add a utility functions for addons to use when they need
a reference to the current event loop.

Currently, `uv_default_loop()` works if the embedder is the
single-threaded default node executable, but even without
the presence of e.g. workers that might not really an API
guarantee for when Node is embedded.

PR-URL: https://github.com/nodejs/node/pull/17109
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-21 08:33:19 +01:00
Daniel Bevenius
b021403b2a test: --enable-static linked executable
The motivation for this commit is to enable projects embedding Node.js
and building with --enable-static to be able to run the test suite and
linter.

Currently when building with --enable-static no node executable
will be created which means that the tests (apart from the cctest) and
linter cannot be run.

This is currently a work in progress and works on MacOS but I need to
run the CI, and manually on different environments to verify that it
works as expected.

PR-URL: https://github.com/nodejs/node/pull/14986
Refs: https://github.com/nodejs/node/issues/14158
Refs: https://github.com/nodejs/node/pull/14892
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-11-16 09:22:13 +01:00
joelostrowski
6ee985f311 tls: implement clientCertEngine option
Add an option 'clientCertEngine' to `tls.createSecureContext()` which gets
wired up to OpenSSL function `SSL_CTX_set_client_cert_engine`. The option
is passed through from `https.request()` as well. This allows using a custom
OpenSSL engine to provide the client certificate.
2017-11-11 13:35:23 -08:00
Nicolas Morel
2054c66e77 test: remove custom message from assertion
The custom message means that the values involved are not reported.
Remove the custom message for a more detailed error message.

PR-URL: https://github.com/nodejs/node/pull/16824
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-11-07 09:50:54 +00:00
Rich Trott
2f47b6869a test: use common.buildType in repl-domain-abort
use `common.buildType` instead of
`process.config.target_defaults.default_configuration` in
repl-domain-abort addon test.

PR-URL: https://github.com/nodejs/node/pull/16538
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-27 09:50:37 -07:00
Michael Dawson
6bc82daef0 n-api: use module name macro
Update tests to use module name macro

PR-URL: https://github.com/nodejs/node/pull/16185
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-15 16:00:29 -07:00
Fadi Asfour
5ea88b7496 test: remove error messages for readability
PR-URL: https://github.com/nodejs/node/pull/16022
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-14 11:42:53 +08:00
Rich Trott
981595c316 test: fix test-esm-addons
Move test-esm-addons to test/addons/hello-world-esm.

Test should now work properly on CI machines where `addons` are not
always built at the expected relative path from the es-modules tests.

Test should now work in Debug builds.

PR-URL: https://github.com/nodejs/node/pull/16174
Fixes: https://github.com/nodejs/node/issues/16155
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-10-13 10:50:02 -07:00
agilbert
16ed116203 test: clean up string concat in dlopen-ping-pong
replace string concatenation with template literals.

PR-URL: https://github.com/nodejs/node/pull/15820
Reviewed-By: Ryan Graham <r.m.graham@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-10-11 14:29:44 +05:30
Ben Noordhuis
9e9c83ea95
test: check that this != new.target in addon
Add two checks that are there for expository reasons as much as they are
sanity checks.

PR-URL: https://github.com/nodejs/node/pull/15681
Refs: https://github.com/nodejs/node-addon-api/issues/142
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-10-02 01:20:27 -03:00