Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
* 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: nodejs/node-addon-api#142
Fixes: nodejs/abi-stable-node#282
  • Loading branch information
Marlyfleitas committed Oct 17, 2017
1 parent 1d4e3b7 commit d452adc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/node_api.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'defines': [
'EXTERNAL_NAPI',
],
'cflags_cc': ['-fvisibility=hidden']
}
]
}
18 changes: 11 additions & 7 deletions src/node_internals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <unistd.h> // 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
Expand All @@ -30,6 +30,15 @@ void EmitAsyncDestroy(v8::Isolate* isolate,
async_context asyncContext) {
}

AsyncResource::AsyncResource(v8::Isolate* isolate,
v8::Local<v8::Object> object,
const char *name) {
}

#endif // NODE_MAJOR_VERSION < 8

#if NODE_MAJOR_VERSION < 8 || NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION < 6

v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
v8::Local<v8::Object> recv,
v8::Local<v8::Function> callback,
Expand All @@ -39,12 +48,7 @@ v8::MaybeLocal<v8::Value> MakeCallback(v8::Isolate* isolate,
return node::MakeCallback(isolate, recv, callback, argc, argv);
}

AsyncResource::AsyncResource(v8::Isolate* isolate,
v8::Local<v8::Object> 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;
Expand Down
2 changes: 1 addition & 1 deletion test/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/typedarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ function test(binding) {

assert.throws(() => {
binding.typedarray.createInvalidTypedArray();
}, /Invalid pointer/);
}, /Invalid (pointer passed as )?argument/);
}

0 comments on commit d452adc

Please sign in to comment.