From ea1f05c6f6ab27e8b0bc267898762296e04d03cd Mon Sep 17 00:00:00 2001 From: John French Date: Mon, 16 Oct 2017 12:50:45 +0300 Subject: [PATCH] Fix test errors * Implement node::MakeCallback between 8.0.0 and 8.6.0 to fix unresolved symbol * Fix error message expectation (was: "Invalid pointer", is: "Invalid argument") * Add -fvisibility=hidden to the compilation of sources of node_api.a so as to avoid conflicts with Node.js symbols Fixes: https://github.com/nodejs/node-addon-api/issues/142 Fixes: https://github.com/nodejs/abi-stable-node/issues/282 --- src/node_api.gyp | 1 + src/node_internals.cc | 18 +++++++++++------- test/function.js | 2 +- test/typedarray.js | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/node_api.gyp b/src/node_api.gyp index 07921db..fa34d83 100644 --- a/src/node_api.gyp +++ b/src/node_api.gyp @@ -13,6 +13,7 @@ 'defines': [ 'EXTERNAL_NAPI', ], + 'cflags_cc': ['-fvisibility=hidden'] } ] } diff --git a/src/node_internals.cc b/src/node_internals.cc index 2ff8afe..c4a7dd8 100644 --- a/src/node_internals.cc +++ b/src/node_internals.cc @@ -10,7 +10,7 @@ #include // getpid #endif -#if NODE_MAJOR_VERSION < 8 +#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6 CallbackScope::CallbackScope(void *work) { } #endif // NODE_MAJOR_VERSION < 8 @@ -30,6 +30,15 @@ void EmitAsyncDestroy(v8::Isolate* isolate, async_context asyncContext) { } +AsyncResource::AsyncResource(v8::Isolate* isolate, + v8::Local object, + const char *name) { +} + +#endif // NODE_MAJOR_VERSION < 8 + +#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6 + v8::MaybeLocal MakeCallback(v8::Isolate* isolate, v8::Local recv, v8::Local callback, @@ -39,12 +48,7 @@ v8::MaybeLocal MakeCallback(v8::Isolate* isolate, return node::MakeCallback(isolate, recv, callback, argc, argv); } -AsyncResource::AsyncResource(v8::Isolate* isolate, - v8::Local object, - const char *name) { -} - -#endif // NODE_MAJOR_VERSION < 8 +#endif // NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6 static void PrintErrorString(const char* format, ...) { va_list ap; diff --git a/test/function.js b/test/function.js index 59134ed..0d75ffc 100644 --- a/test/function.js +++ b/test/function.js @@ -46,7 +46,7 @@ function test(binding) { assert.throws(() => { binding.function.callWithInvalidReceiver(); - }, /Invalid pointer/); + }, /Invalid (pointer passed as )?argument/); obj = binding.function.callConstructorWithArgs(testConstructor, 5, 6, 7); assert(obj instanceof testConstructor); diff --git a/test/typedarray.js b/test/typedarray.js index f5ffca2..9aa880c 100644 --- a/test/typedarray.js +++ b/test/typedarray.js @@ -66,5 +66,5 @@ function test(binding) { assert.throws(() => { binding.typedarray.createInvalidTypedArray(); - }, /Invalid pointer/); + }, /Invalid (pointer passed as )?argument/); }