Anthony Tuininga
d3de1ed653
n-api: improve performance creating strings
...
Improve performance creating strings using N-API by ensuring that the
strings are not internalized.
Added test cases for latin-1 and utf-16 strings.
PR-URL: https://github.com/nodejs/node/pull/26439
Fixes: https://github.com/nodejs/node/issues/26437
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-04-15 23:50:11 -04:00
Gabriel Schulhof
d6ffabc37f
n-api: mark thread-safe function as stable
...
Fixes: https://github.com/nodejs/node/issues/24249
PR-URL: https://github.com/nodejs/node/pull/25556
Backport-PR-URL: https://github.com/nodejs/node/pull/25648
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2019-03-19 23:56:33 +00:00
Gireesh Punathil
60db455961
test: mark test_threadsafe_function/test as flaky
...
The test fails consistently on windows-fanned with vs2017.
mark it as flaky while the issue is being progressed, and
to keep CI green / amber.
Ref: https://github.com/nodejs/node/issues/23621
Backport-PR-URL: https://github.com/nodejs/node/pull/25002
PR-URL: https://github.com/nodejs/node/pull/24714
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-02-28 23:40:11 +11:00
Gabriel Schulhof
367505940a
n-api: guard against cond null dereference
...
A condition variable is only created by the thread-safe function if the
queue size is set to something larger than zero. This adds null-checks
around the condition variable and tests for the case where the queue
size is zero.
Fixes: https://github.com/nodejs/help/issues/1387
PR-URL: https://github.com/nodejs/node/pull/21871
Backport-PR-URL: https://github.com/nodejs/node/pull/25002
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2019-02-28 23:40:10 +11:00
Gabriel Schulhof
759a0180b5
n-api: add API for asynchronous functions
...
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`,
and a `v8::Persistent<v8::Function>` to make it possible to call into JS
from another thread. The API accepts a void data pointer and a callback
which will be invoked on the loop thread and which will receive the
`napi_value` representing the JavaScript function to call so as to
perform the call into JS. The callback is run inside a
`node::CallbackScope`.
A `std::queue<void*>` is used to store calls from the secondary
threads, and an idle loop is started by the `uv_async_t` callback on the
loop thread to drain the queue, calling into JS with each item.
Items can be added to the queue blockingly or non-blockingly.
The thread-safe function can be referenced or unreferenced, with the
same semantics as libuv handles.
Re: https://github.com/nodejs/help/issues/1035
Re: https://github.com/nodejs/node/issues/20964
Fixes: https://github.com/nodejs/node/issues/13512
Backport-PR-URL: https://github.com/nodejs/node/pull/25002
PR-URL: https://github.com/nodejs/node/pull/17887
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2019-02-28 23:40:10 +11:00
Anna Henningsen
66343c546c
src: add environment cleanup hooks
...
This adds pairs of methods to the `Environment` class and to public APIs
which can add and remove cleanup handlers.
Unlike `AtExit`, this API targets addon developers rather than
embedders, giving them (and Node\u2019s internals) the ability to register
per-`Environment` cleanup work.
We may want to replace `AtExit` with this API at some point.
Many thanks for Stephen Belanger for reviewing the original version of
this commit in the Ayo.js project.
Refs: https://github.com/ayojs/ayo/pull/82
Backport-PR-URL: https://github.com/nodejs/node/pull/22435
PR-URL: https://github.com/nodejs/node/pull/19377
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-09-06 09:43:54 -07:00
Gabriel Schulhof
35a8ff7e55
n-api: create functions directly
...
Avoid using `v8::FunctionTemplate::New()` when using
`v8::Function::New()` suffices. This ensures that individual functions
can be gc-ed and that functions can be created dynamically without
running out of memory.
Backport-PR-URL: https://github.com/nodejs/node/pull/22202
PR-URL: https://github.com/nodejs/node/pull/21688
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Yang Guo <yangguo@chromium.org >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2018-08-17 17:05:06 -04:00
Ruben Bridgewater
d55e4adc3d
test,benchmark,doc: enable dot-notation rule
...
This enables the eslint dot-notation rule for all code instead of
only in /lib.
PR-URL: https://github.com/nodejs/node/pull/18749
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matheus Marchini <matheus@sthima.com >
2018-08-16 01:59:08 -04:00
Gabriel Schulhof
7033bbaa01
n-api: throw when entry point is null
...
Backport-PR-URL: https://github.com/nodejs/node/pull/21732
PR-URL: https://github.com/nodejs/node/pull/20779
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-08-16 11:38:52 +10:00
Michael Dawson
ad862a0114
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-08-16 11:38:50 +10:00
Michael Dawson
0b2f52706d
n-api: take n-api out of experimental
...
Take n-api out of experimental as per:
https://github.com/nodejs/TSC/issues/501
Backport-PR-URL: https://github.com/nodejs/node/pull/21083
PR-URL: https://github.com/nodejs/node/pull/19262
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
2018-08-16 11:38:49 +10:00
Kyle Farnung
07a6770614
n-api: add more int64_t tests
...
* Updated tests for `Number` and `int32_t`
* Added new tests for `int64_t`
* Updated N-API `int64_t` behavior to return zero for all non-finite
numbers
* Clarified the documentation for these calls.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19402
Refs: https://github.com/nodejs/node-chakracore/pull/500
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-05-01 17:16:36 -04:00
Gabriel Schulhof
8b3ef4660a
n-api: back up env before finalize
...
Heed the comment to not use fields of a Reference after calling its
finalize callback, because such a call may destroy the Reference.
Fixes: https://github.com/nodejs/node/issues/19673
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19718
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-05-01 17:16:36 -04:00
Gabriel Schulhof
92f699e021
n-api: ensure in-module exceptions are propagated
...
Whenever we call into an addon, whether it is for a callback, for
module init, or for async work-related reasons, we should make sure
that
* the last error is cleared,
* the scopes before the call are the same as after, and
* if an exception was thrown and captured inside the module, then it is
re-thrown after the call.
Therefore we should call into the module in a unified fashion. This
change introduces the macro NAPI_CALL_INTO_MODULE() which should be
used whenever invoking a callback provided by the module.
Fixes: https://github.com/nodejs/node/issues/19437
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19537
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:36 -04:00
Michael Dawson
367113f5d7
n-api: bump version of n-api supported
...
Bump the version due to additions to the api.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19497
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-05-01 17:16:36 -04:00
Gabriel Schulhof
24b8bb6708
n-api: re-write test_make_callback
...
This re-writes the test in C by dropping std::vector<napi_value> in
favour of a C99 variable length array, and by dropping the anonymous
namespace in favour of static function declarations.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19448
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:35 -04:00
Mathias Buus
3a6b7e610d
n-api: add napi_fatal_exception
...
Add function to trigger and uncaught exception.
Useful if an async callback throws an exception with
no way to recover.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19337
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:35 -04:00
Gabriel Schulhof
9949d55ae9
n-api: separate out async_hooks test
...
Place the test_make_callback async_hooks-related test into its own file.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19392
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:35 -04:00
Michael Dawson
f29d8e0e8d
n-api: add missing exception checking
...
Add checks for a pending exception in napi_make_callback
after the callback has been invoked. If there is a pending
exception then we need to avoid checking the result as that
will not be able to complete properly.
Add additional checks to the unit test for napi_make_callback
to catch this case.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19362
Fixes: https://github.com/nodejs/node-addon-api/issues/235
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-05-01 17:16:34 -04:00
Kyle Farnung
584fadc605
n-api,test: add int64 bounds tests
...
Added some simple tests to verify that the int64 API is correctly
handling numbers greater than 32-bits. This is a basic test, but
verifies that an implementer hasn't truncated back to 32-bits.
Refs: https://github.com/nodejs/node-chakracore/pull/496
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19309
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-05-01 17:16:34 -04:00
Taylor Woll
4c1181dc02
n-api,test: add a new.target test to addons-napi
...
Added a N-API test to verify new.target behavior.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19236
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:34 -04:00
Gabriel Schulhof
faf94b1c49
n-api: resolve promise in test
...
The last promise created by the test for the purposes of making sure
that its type is indeed a promise needs to be resolved so as to avoid
having it left in the pending state at the end of the test.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19245
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:33 -04:00
Gabriel Schulhof
b26410e86f
n-api: update reference test
...
Remove the necessity for allocating on the heap, and assert that the
correct pointer gets passed to the finalizer.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19086
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: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:33 -04:00
Gabriel Schulhof
cb3f90a1a9
n-api: fix object test
...
Passing a pointer to a static integer is sufficient for the test.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/19039
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com >
2018-05-01 17:16:33 -04:00
cjihrig
6129ff4b99
test: remove unnecessary timer
...
The timer in NAPI's test_callback_scope/test-resolve-async.js
can be removed. If the test fails, it will timeout on its own.
The extra timer increases the chances of the test being
flaky.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18719
Fixes: https://github.com/nodejs/node/issues/18702
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-05-01 17:16:32 -04:00
Jack Horton
2838f9b150
test: convert new tests to use error types
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18581
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-05-01 17:16:32 -04:00
Bhavani Shankar
5c0983e5a2
test: improve error message output
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18498
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:31 -04:00
Gabriel Schulhof
9244e1d234
n-api: remove extra reference from test
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18542
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-05-01 17:16:31 -04:00
Michael Dawson
927fc0b19f
n-api: add methods to open/close callback scope
...
Add support for the following methods;
napi_open_callback_scope
napi_close_callback_scope
These are needed when running asynchronous methods directly
using uv.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18089
Fixes: https://github.com/nodejs/node/issues/15604
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2018-05-01 17:16:31 -04:00
Ben Wilcox
bebcdfe382
test: show pending exception error in napi tests
...
Shows the result of the wasPending in the error message if the
assertion fails.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18413
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-05-01 17:16:30 -04:00
Aaron Kau
af655f586c
n-api: change assert ok check to notStrictEqual.
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18414
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-05-01 17:16:30 -04:00
Rich Trott
5b1b74c5a5
test: refactor addons-napi/test_exception/test.js
...
* provide block scoping to prevent unintended side effects
* remove confusing and unnecessary assertion message
* use consisitent `actual, expected` argument order for assertions
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18340
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-05-01 17:16:29 -04:00
Anatoli Papirovski
e15f57745d
timers: allow Immediates to be unrefed
...
Refactor Immediates handling to allow for them to be unrefed, similar
to setTimeout, but without extra handles.
Document the new `immediate.ref()` and `immediate.unref()` methods.
Add SetImmediateUnref on the C++ side.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18139
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-05-01 17:16:29 -04:00
furstenheim
8cfa87832d
test: fixed typos in napi test
...
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18148
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-05-01 17:16:29 -04:00
Jinho Bang
ca10fda064
n-api: throw RangeError napi_create_typedarray()
...
According to the ECMA spec, we should throw a RangeError in the
following cases:
- `(length * elementSize) + offset` > the size of the array passed in
- `offset % elementSize` != `0`
In the current implementation, this check was omitted. So, the following
code will cause a crash.
```
napi_create_typedarray(env, napi_uint16_array, 2 /* length */,
buffer, 1 /* byte_offset */, &output_array);
```
This change fixes the problem and write some related tests.
Refs:
https://tc39.github.io/ecma262/#sec-typedarray-buffer-byteoffset-length
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/18037
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-05-01 17:16:28 -04:00
Jinho Bang
48be8a4793
n-api: throw RangeError in napi_create_dataview() with invalid range
...
The API is required that `byte_length + byte_offset` is less than or
equal to the size in bytes of the array passed in. If not, a RangeError
exception is raised[1].
[1] https://nodejs.org/api/n-api.html#n_api_napi_create_dataview
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/17869
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-05-01 17:16:28 -04:00
Nicholas Drane
ad8c079af7
test: remove ambiguous error messages from test_error
...
assert.strictEqual accepts 3 arguments, the last of which allows for
user-specified error message to be thrown when the assertion fails.
Unfortunately, this error message is less helpful than the default when
it is vague. This commit removes vague, user-specified error messages,
instead relying on clearer, default error messages.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/17812
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-05-01 17:16:27 -04:00
Rich Trott
2e100c82be
test: remove literals that obscure assert messages
...
Remove string literals as messages to `assert.strictEqual()`. They can
be misleading here (where perhaps the reason an assertino failed isn't
that the deleter wasn't called but rather was called too many times.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/17642
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-05-01 17:16:27 -04:00
babygoat
077e1870ae
test: add unhandled rejection guard
...
Add an unhandled rejection function in
addons-napi/test_promise/test.js. Also, add a
rejection handler to catch the unhandled rejection
after introducing the guard and test the reason
code.
Backport-PR-URL: https://github.com/nodejs/node/pull/19265
PR-URL: https://github.com/nodejs/node/pull/17275
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-05-01 17:16:26 -04:00
Anna Henningsen
3d2d051ed0
n-api: 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.
While the libuv API is not directly part of N-API, it
provides a quite stable C API as well, and is tightly
integrated with Node itself.
As a particular use case, without access to the event loop
it is hard to do something interesting from inside a N-API
finalizer function, since calls into JS and therefore virtually
all other N-API functions are not allowed.
PR-URL: https://github.com/nodejs/node/pull/17109
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-01-15 17:54:07 -05:00
Daniel Bevenius
47322e67c4
tools: add cpplint rule for NULL usage
...
This commit is a suggestion for adding a rule for NULL usages in the
code base. This will currently report a number of errors which could be
ignored using // NOLINT (readability/null_usage)
PR-URL: https://github.com/nodejs/node/pull/17373
Backport-PR-URL: https://github.com/nodejs/node/pull/17873
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 >
2018-01-03 23:27:43 +00:00
Leko
e01cd821f5
test: replace assert.throws with common.expectsError
...
PR-URL: https://github.com/nodejs/node/pull/17445
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-12-20 01:59:42 +00:00
John Byrne
eb8344b3a9
test: use default assertion messages
...
The string literal messages in addons-napi/test_buffer/test.js are less
helpful than the default messages, so use the default messages.
PR-URL: https://github.com/nodejs/node/pull/16808
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2017-12-13 16:56:18 +00:00
Attila Gonda
d2b32ce074
test: add detailed message for assertion failure
...
PR-URL: https://github.com/nodejs/node/pull/16812
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2017-12-13 16:54:28 +00:00
Paul Blanche
55bf57dc9a
test: improve assert messages in napi exception test
...
Include unexpected value in assertion messages.
PR-URL: https://github.com/nodejs/node/pull/16820
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2017-12-13 16:54:28 +00:00
Paul Ashfield
25ff7bf1cd
test: improve error emssage reporting in testNapiRun.js
...
PR-URL: https://github.com/nodejs/node/pull/16821
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2017-12-13 16:54:27 +00:00
ka3e
2d63b65aed
test: refactor addons-napi/test_promise/test.js
...
* remove custom messages for assert that conceal values
* add comment explaining test
* add block scoping
PR-URL: https://github.com/nodejs/node/pull/16814
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-12-13 16:18:43 +00:00
Matthew Cantelon
bac2aff23d
test: include actual value in assertion message
...
PR-URL: https://github.com/nodejs/node/pull/15935
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2017-10-31 00:15:07 +00:00
Jayson D. Henkel
d7b4ad89fb
test: improve message for assert.strictEqual()
...
PR-URL: https://github.com/nodejs/node/pull/16013
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Evan Lucas <evanlucas@me.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2017-10-23 17:23:02 -04:00
Anna Henningsen
0a52479805
n-api: check against invalid handle scope usage
...
Fixes: https://github.com/nodejs/node/issues/16175
PR-URL: https://github.com/nodejs/node/pull/16201
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-10-18 08:53:32 -07:00