Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
f46649b
util: print External address from inspect
rosaxxny Jul 16, 2020
465968c
console: document the behavior of console.assert()
Jul 23, 2020
692a735
doc: use sentence-case for headers in SECURITY.md
Trott Jul 27, 2020
70e9ece
build: toolchain.gypi and node_gyp.py cleanup
Jul 9, 2020
14656e1
async_hooks: don't reuse resource in HttpAgent when queued
puzpuzpuz Jul 20, 2020
9c442f9
test: remove unneeded flag check in test-vm-memleak
Trott Jul 27, 2020
2703fe4
n-api: simplify bigint-from-word creation
Jul 29, 2020
70cf3cb
build: auto start Jenkins CI via PR labels
mmarchini Jun 27, 2020
c8104f3
doc: update .mailmap for mmarchini
mmarchini Jul 31, 2020
7a28c3d
doc: update mmarchini contact info
mmarchini Jul 31, 2020
212d17f
doc: add mmarchini pronouns
mmarchini Jul 31, 2020
8cc9e5e
n-api: support type-tagging objects
Jun 14, 2019
b69ff2f
doc: use consistent capitalization for addons
Trott Jul 28, 2020
f393ae9
doc: simplify and clarify console.assert() documentation
Trott Jul 29, 2020
be23e23
doc: use consistent spelling for "falsy"
Trott Jul 29, 2020
4af5dbd
build: fix auto-start-ci script path
mmarchini Jul 31, 2020
befbaf3
build: don't run auto-start-ci on push
mmarchini Aug 1, 2020
44e6c01
esm: fix hook mistypes and links to types
DerekNonGeneric Jul 7, 2020
c4457d8
benchmark: always throw the same Error instance
addaleax Jul 26, 2020
335cb0d
lib: absorb `path` error cases
gireeshpunathil Jul 26, 2020
e2bea73
doc: clarify N-API version 1
mhdawson Jul 13, 2020
c1abc8d
src: fix unused namespace member in node_util
puzpuzpuz Jul 30, 2020
36fd3da
http: provide keep-alive timeout response header
ronag Jul 30, 2020
d7eaf3a
doc: revise N-API versions matrix text
Trott Jul 30, 2020
7322e58
http: reset headers timeout on headers complete
ronag Jul 31, 2020
10dd7a0
doc: add DerekNonGeneric to collaborators
DerekNonGeneric Aug 2, 2020
0a9389b
doc: mention null special-case for `napi_typeof`
goto-bus-stop Jul 31, 2020
9af6264
async_hooks: execute destroy hooks earlier
Flarna Jul 13, 2020
7c4e1db
async_hooks: fix resource stack for deep stacks
addaleax Jul 31, 2020
283f5c3
test: fix flaky http-parser-timeout-reset
ronag Aug 3, 2020
1b0d3b2
doc: document the connection event for HTTP2 & TLS servers
pimterry Jul 27, 2020
dba869e
test: change Fixes: to Refs:
Trott Jul 30, 2020
18ca52d
async_hooks: fix id assignment in fast-path promise hook
puzpuzpuz Jul 28, 2020
2d2ea99
tools: add meta.fixable to fixable lint rules
cjihrig Aug 1, 2020
72f357a
tools: update ESLint to 7.6.0
cjihrig Aug 1, 2020
ae64ec4
repl: give repl entries unique names
bmeck Jul 14, 2020
d6b0a40
test: replace flaky pummel regression tests
addaleax Jul 27, 2020
d972c54
doc: clarify process.title inconsistencies
coreybutler Jul 29, 2020
ba137e0
doc: add release key for Ruy Adorno
ruyadorno Aug 5, 2020
938842e
repl: improve static import error message in repl
MylesBorins May 27, 2020
338994f
build: increase startCI verbosity and fix job name
mmarchini Aug 5, 2020
3eabb7e
policy: increase tests via permutation matrix
bmeck Jul 16, 2020
7be68cd
test: convert most N-API tests from C++ to C
Aug 3, 2020
d0a599a
module: unflag Top-Level Await
MylesBorins Jul 29, 2020
c21e62f
module: handle Top-Level Await non-fulfills better
addaleax Aug 6, 2020
22f499f
build: enable build for node-v8 push
gengjiawen Aug 5, 2020
221802d
build: run CI on release branches
codebytere Aug 6, 2020
4dbb931
async_hooks: don't read resource if ALS is disabled
Flarna Aug 3, 2020
ffd2c7a
meta: enable http2 team for CODEOWNERS
Trott Jul 28, 2020
a503470
crypto: add OP flag constants added in OpenSSL v1.1.1
mkrawczuk Jun 17, 2020
a0caf8c
doc: fix typo in path.md
Jul 29, 2020
767a5cb
doc: update fs.watch() availability for IBM i
Aug 3, 2020
4cd9c4f
test: add debugging for test-https-foafssl.js
Trott Aug 2, 2020
27333b1
test: add debugging for callbacks in test-https-foafssl.js
Trott Aug 2, 2020
7b4d40c
doc: edit process.title note for brevity and clarity
Trott Aug 4, 2020
8ff9caa
deps: update to uvwasi 0.0.10
cjihrig Aug 4, 2020
c4d373b
wasi: add __wasi_fd_filestat_set_times() test
cjihrig Aug 4, 2020
3132878
src: fix `size` underflow in CallbackQueue
addaleax Aug 7, 2020
4369c2a
src: spin shutdown loop while immediates are pending
addaleax Aug 7, 2020
f0b364f
build: do not run auto-start-ci on forks
evanlucas Aug 6, 2020
df8f9a4
doc: add Ricky Zhou to collaborators
rickyes Aug 8, 2020
33777a3
test: fix wrong method call
gengjiawen Aug 5, 2020
3ecb16b
repl: use _REPL_ in user-facing text
Trott Aug 6, 2020
7887ce2
net: don't return the stream object from onStreamRead
robey Jul 15, 2020
0c4226e
repl: use _Node.js_ in user-facing REPL text
Trott Aug 6, 2020
ef4fb68
async_hooks: add AsyncResource.bind utility
jasnell Jul 31, 2020
0730c76
async_hooks: improve property descriptors in als.bind
Flarna Aug 4, 2020
641a5fb
async_hooks: avoid unneeded AsyncResource creation
Flarna Aug 3, 2020
8630f34
n-api,src: provide asynchronous cleanup hooks
addaleax Jul 31, 2020
db6f9bd
async_hooks: avoid GC tracking of AsyncResource in ALS
Flarna Aug 3, 2020
4ed89a3
n-api: fix use-after-free with napi_remove_async_cleanup_hook
addaleax Aug 7, 2020
a944dab
doc: use _Class Method_ in async_hooks.md
Trott Aug 4, 2020
e97fe4b
src: fix linter failures
addaleax Jul 31, 2020
af0cfeb
tools: fix C++ import checker argument expansion
addaleax Jul 31, 2020
5b5f5f9
doc: tidy some addons.md text
Trott Aug 6, 2020
4efc5f6
lib: use non-symbols in isURLInstance check
codebytere Aug 4, 2020
41d0cf7
doc: use _Static method_ instead of _Class Method_
Trott Aug 7, 2020
bd00f26
meta: uncomment all codeowners
mmarchini Aug 7, 2020
b45ea94
2020-08-11, Version 14.8.0 (Current)
codebytere Aug 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: convert most N-API tests from C++ to C
* Prefix functions with `static` to make them local
* Remove anonymous namespaces
* `nullptr` -> `NULL`
* .cc -> .c and update binding.gyp
* `static_cast<x>()` -> `(x)()`
* Replace `new`/`delete` with `malloc()`/`free()`
  (only in test_callback_scope)
* Move lambda out and convert to local function
  (only in test_callback_scope)
* Remove superfluous `#include <vector>`
  (only in test_callback_scope_recurse)

Some tests are best left as C++.

```bash
ls -l test/{node-api,js-native-api}/*/*.cc
```

for those remaining as C++ tests.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: #34615
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
  • Loading branch information
Gabriel Schulhof authored and codebytere committed Aug 11, 2020
commit 7be68cdab0ea802a5c47470c5408ab4679588b6d
2 changes: 1 addition & 1 deletion test/node-api/test_async/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"targets": [
{
"target_name": "test_async",
"sources": [ "test_async.cc" ]
"sources": [ "test_async.c" ]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ typedef struct {
napi_async_work _request;
} carrier;

carrier the_carrier;
carrier async_carrier[MAX_CANCEL_THREADS];
static carrier the_carrier;
static carrier async_carrier[MAX_CANCEL_THREADS];

void Execute(napi_env env, void* data) {
static void Execute(napi_env env, void* data) {
#if defined _WIN32
Sleep(1000);
#else
sleep(1);
#endif
carrier* c = static_cast<carrier*>(data);
carrier* c = (carrier*)(data);

assert(c == &the_carrier);

c->_output = c->_input * 2;
}

void Complete(napi_env env, napi_status status, void* data) {
carrier* c = static_cast<carrier*>(data);
static void Complete(napi_env env, napi_status status, void* data) {
carrier* c = (carrier*)(data);

if (c != &the_carrier) {
napi_throw_type_error(env, nullptr, "Wrong data parameter to Complete.");
napi_throw_type_error(env, NULL, "Wrong data parameter to Complete.");
return;
}

if (status != napi_ok) {
napi_throw_type_error(env, nullptr, "Execute callback failed.");
napi_throw_type_error(env, NULL, "Execute callback failed.");
return;
}

Expand All @@ -66,7 +66,7 @@ void Complete(napi_env env, napi_status status, void* data) {
NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, c->_request));
}

napi_value Test(napi_env env, napi_callback_info info) {
static napi_value Test(napi_env env, napi_callback_info info) {
size_t argc = 3;
napi_value argv[3];
napi_value _this;
Expand Down Expand Up @@ -101,16 +101,16 @@ napi_value Test(napi_env env, napi_callback_info info) {
NAPI_CALL(env,
napi_queue_async_work(env, the_carrier._request));

return nullptr;
return NULL;
}

void BusyCancelComplete(napi_env env, napi_status status, void* data) {
carrier* c = static_cast<carrier*>(data);
static void BusyCancelComplete(napi_env env, napi_status status, void* data) {
carrier* c = (carrier*)(data);
NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, c->_request));
}

void CancelComplete(napi_env env, napi_status status, void* data) {
carrier* c = static_cast<carrier*>(data);
static void CancelComplete(napi_env env, napi_status status, void* data) {
carrier* c = (carrier*)(data);

if (status == napi_cancelled) {
// ok we got the status we expected so make the callback to
Expand All @@ -122,22 +122,22 @@ void CancelComplete(napi_env env, napi_status status, void* data) {
NAPI_CALL_RETURN_VOID(env, napi_get_global(env, &global));
napi_value result;
NAPI_CALL_RETURN_VOID(env,
napi_call_function(env, global, callback, 0, nullptr, &result));
napi_call_function(env, global, callback, 0, NULL, &result));
}

NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, c->_request));
NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, c->_callback));
}

void CancelExecute(napi_env env, void* data) {
static void CancelExecute(napi_env env, void* data) {
#if defined _WIN32
Sleep(1000);
#else
sleep(1);
#endif
}

napi_value TestCancel(napi_env env, napi_callback_info info) {
static napi_value TestCancel(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value argv[1];
napi_value _this;
Expand All @@ -150,7 +150,7 @@ napi_value TestCancel(napi_env env, napi_callback_info info) {
// make sure the work we are going to cancel will not be
// able to start by using all the threads in the pool
for (int i = 1; i < MAX_CANCEL_THREADS; i++) {
NAPI_CALL(env, napi_create_async_work(env, nullptr, resource_name,
NAPI_CALL(env, napi_create_async_work(env, NULL, resource_name,
CancelExecute, BusyCancelComplete,
&async_carrier[i], &async_carrier[i]._request));
NAPI_CALL(env, napi_queue_async_work(env, async_carrier[i]._request));
Expand All @@ -162,20 +162,20 @@ napi_value TestCancel(napi_env env, napi_callback_info info) {
// workers above.
NAPI_CALL(env,
napi_get_cb_info(env, info, &argc, argv, &_this, &data));
NAPI_CALL(env, napi_create_async_work(env, nullptr, resource_name,
NAPI_CALL(env, napi_create_async_work(env, NULL, resource_name,
CancelExecute, CancelComplete,
&async_carrier[0], &async_carrier[0]._request));
NAPI_CALL(env,
napi_create_reference(env, argv[0], 1, &async_carrier[0]._callback));
NAPI_CALL(env, napi_queue_async_work(env, async_carrier[0]._request));
NAPI_CALL(env, napi_cancel_async_work(env, async_carrier[0]._request));
return nullptr;
return NULL;
}

struct {
napi_ref ref;
napi_async_work work;
} repeated_work_info = { nullptr, nullptr };
} repeated_work_info = { NULL, NULL };

static void RepeatedWorkerThread(napi_env env, void* data) {}

Expand All @@ -187,33 +187,33 @@ static void RepeatedWorkComplete(napi_env env, napi_status status, void* data) {
napi_delete_async_work(env, repeated_work_info.work));
NAPI_CALL_RETURN_VOID(env,
napi_delete_reference(env, repeated_work_info.ref));
repeated_work_info.work = nullptr;
repeated_work_info.ref = nullptr;
repeated_work_info.work = NULL;
repeated_work_info.ref = NULL;
NAPI_CALL_RETURN_VOID(env,
napi_create_uint32(env, (uint32_t)status, &js_status));
NAPI_CALL_RETURN_VOID(env,
napi_call_function(env, cb, cb, 1, &js_status, nullptr));
napi_call_function(env, cb, cb, 1, &js_status, NULL));
}

static napi_value DoRepeatedWork(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value cb, name;
NAPI_ASSERT(env, repeated_work_info.ref == nullptr,
NAPI_ASSERT(env, repeated_work_info.ref == NULL,
"Reference left over from previous work");
NAPI_ASSERT(env, repeated_work_info.work == nullptr,
NAPI_ASSERT(env, repeated_work_info.work == NULL,
"Work pointer left over from previous work");
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &cb, nullptr, nullptr));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &cb, NULL, NULL));
NAPI_CALL(env, napi_create_reference(env, cb, 1, &repeated_work_info.ref));
NAPI_CALL(env,
napi_create_string_utf8(env, "Repeated Work", NAPI_AUTO_LENGTH, &name));
NAPI_CALL(env,
napi_create_async_work(env, nullptr, name, RepeatedWorkerThread,
napi_create_async_work(env, NULL, name, RepeatedWorkerThread,
RepeatedWorkComplete, &repeated_work_info, &repeated_work_info.work));
NAPI_CALL(env, napi_queue_async_work(env, repeated_work_info.work));
return nullptr;
return NULL;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor properties[] = {
DECLARE_NAPI_PROPERTY("Test", Test),
DECLARE_NAPI_PROPERTY("TestCancel", TestCancel),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#include <stdlib.h>
#include "node_api.h"
#include "uv.h"
#include "../../js-native-api/common.h"

namespace {

napi_value RunInCallbackScope(napi_env env, napi_callback_info info) {
static napi_value RunInCallbackScope(napi_env env, napi_callback_info info) {
size_t argc;
napi_value args[3];

NAPI_CALL(env, napi_get_cb_info(env, info, &argc, nullptr, nullptr, nullptr));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, NULL, NULL, NULL));
NAPI_ASSERT(env, argc == 3 , "Wrong number of arguments");

NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));

napi_valuetype valuetype;
NAPI_CALL(env, napi_typeof(env, args[0], &valuetype));
Expand All @@ -29,7 +28,7 @@ napi_value RunInCallbackScope(napi_env env, napi_callback_info info) {
napi_async_context context;
NAPI_CALL(env, napi_async_init(env, args[0], args[1], &context));

napi_callback_scope scope = nullptr;
napi_callback_scope scope = NULL;
NAPI_CALL(
env,
napi_open_callback_scope(env,
Expand All @@ -39,9 +38,9 @@ napi_value RunInCallbackScope(napi_env env, napi_callback_info info) {

// if the function has an exception pending after the call that is ok
// so we don't use NAPI_CALL as we must close the callback scope regardless
napi_value result = nullptr;
napi_value result = NULL;
napi_status function_call_result =
napi_call_function(env, args[0], args[2], 0, nullptr, &result);
napi_call_function(env, args[0], args[2], 0, NULL, &result);
if (function_call_result != napi_ok) {
GET_AND_THROW_LAST_ERROR((env));
}
Expand All @@ -52,29 +51,29 @@ napi_value RunInCallbackScope(napi_env env, napi_callback_info info) {
return result;
}

static napi_env shared_env = nullptr;
static napi_deferred deferred = nullptr;
static napi_env shared_env = NULL;
static napi_deferred deferred = NULL;

static void Callback(uv_work_t* req, int ignored) {
napi_env env = shared_env;

napi_handle_scope handle_scope = nullptr;
napi_handle_scope handle_scope = NULL;
NAPI_CALL_RETURN_VOID(env, napi_open_handle_scope(env, &handle_scope));

napi_value resource_name;
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
env, "test", NAPI_AUTO_LENGTH, &resource_name));
napi_async_context context;
NAPI_CALL_RETURN_VOID(env,
napi_async_init(env, nullptr, resource_name, &context));
napi_async_init(env, NULL, resource_name, &context));

napi_value resource_object;
NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &resource_object));

napi_value undefined_value;
NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined_value));

napi_callback_scope scope = nullptr;
napi_callback_scope scope = NULL;
NAPI_CALL_RETURN_VOID(env, napi_open_callback_scope(env,
resource_object,
context,
Expand All @@ -87,28 +86,30 @@ static void Callback(uv_work_t* req, int ignored) {

NAPI_CALL_RETURN_VOID(env, napi_close_handle_scope(env, handle_scope));
NAPI_CALL_RETURN_VOID(env, napi_async_destroy(env, context));
delete req;
free(req);
}

napi_value TestResolveAsync(napi_env env, napi_callback_info info) {
napi_value promise = nullptr;
if (deferred == nullptr) {
static void NoopWork(uv_work_t* work) { (void) work; }

static napi_value TestResolveAsync(napi_env env, napi_callback_info info) {
napi_value promise = NULL;
if (deferred == NULL) {
shared_env = env;
NAPI_CALL(env, napi_create_promise(env, &deferred, &promise));

uv_loop_t* loop = nullptr;
uv_loop_t* loop = NULL;
NAPI_CALL(env, napi_get_uv_event_loop(env, &loop));

uv_work_t* req = new uv_work_t();
uv_work_t* req = malloc(sizeof(*req));
uv_queue_work(loop,
req,
[](uv_work_t*) {},
NoopWork,
Callback);
}
return promise;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor descriptors[] = {
DECLARE_NAPI_PROPERTY("runInCallbackScope", RunInCallbackScope),
DECLARE_NAPI_PROPERTY("testResolveAsync", TestResolveAsync)
Expand All @@ -120,6 +121,4 @@ napi_value Init(napi_env env, napi_value exports) {
return exports;
}

} // anonymous namespace

NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
2 changes: 1 addition & 1 deletion test/node-api/test_callback_scope/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
'target_name': 'binding',
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
'sources': [ 'binding.cc' ]
'sources': [ 'binding.c' ]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
#include "uv.h"
#include "../../js-native-api/common.h"

namespace {

void cleanup(void* arg) {
printf("cleanup(%d)\n", *static_cast<int*>(arg));
static void cleanup(void* arg) {
printf("cleanup(%d)\n", *(int*)(arg));
}

int secret = 42;
int wrong_secret = 17;
static int secret = 42;
static int wrong_secret = 17;

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_add_env_cleanup_hook(env, cleanup, &wrong_secret);
napi_add_env_cleanup_hook(env, cleanup, &secret);
napi_remove_env_cleanup_hook(env, cleanup, &wrong_secret);

return nullptr;
return NULL;
}

} // anonymous namespace

NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
2 changes: 1 addition & 1 deletion test/node-api/test_cleanup_hook/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
'target_name': 'binding',
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
'sources': [ 'binding.cc' ]
'sources': [ 'binding.c' ]
}
]
}
Loading