File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ let testModules = [
5555 'objectwrap_constructor_exception' ,
5656 'objectwrap-removewrap' ,
5757 'objectwrap_multiple_inheritance' ,
58+ 'objectwrap_worker_thread' ,
5859 'objectreference' ,
5960 'reference' ,
6061 'version_management'
@@ -90,6 +91,10 @@ if (napiVersion < 6) {
9091 testModules . splice ( testModules . indexOf ( 'typedarray-bigint' ) , 1 ) ;
9192}
9293
94+ if ( majorNodeVersion < 12 ) {
95+ testModules . splice ( testModules . indexOf ( 'objectwrap_worker_thread' ) , 1 ) ;
96+ }
97+
9398if ( typeof global . gc === 'function' ) {
9499 ( async function ( ) {
95100 console . log ( `Testing with N-API Version '${ napiVersion } '.` ) ;
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ class Test : public Napi::ObjectWrap<Test> {
4040 info.This ().As <Napi::Object>().DefineProperty (
4141 Napi::PropertyDescriptor::Accessor<OwnPropertyGetter>(" ownPropertyT" ,
4242 napi_enumerable, this ));
43+
44+ bufref_ = Napi::Persistent (Napi::Buffer<uint8_t >::New (
45+ Env (),
46+ static_cast <uint8_t *>(malloc (1 )),
47+ 1 ,
48+ [](Napi::Env, uint8_t * bufaddr) {
49+ free (bufaddr);
50+ }));
4351 }
4452
4553 static Napi::Value OwnPropertyGetter (const Napi::CallbackInfo& info) {
@@ -183,6 +191,8 @@ class Test : public Napi::ObjectWrap<Test> {
183191 Napi::FunctionReference finalizeCb_;
184192
185193 static std::string s_staticMethodText;
194+
195+ Napi::Reference<Napi::Buffer<uint8_t >> bufref_;
186196};
187197
188198std::string Test::s_staticMethodText;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const buildType = process . config . target_defaults . default_configuration ;
3+ const { Worker, isMainThread } = require ( 'worker_threads' ) ;
4+
5+ if ( isMainThread ) {
6+ new Worker ( __filename ) ;
7+ } else {
8+ const test = binding => {
9+ new binding . objectwrap . Test ( ) ;
10+ } ;
11+
12+ test ( require ( `./build/${ buildType } /binding.node` ) ) ;
13+ test ( require ( `./build/${ buildType } /binding_noexcept.node` ) ) ;
14+ }
You can’t perform that action at this time.
0 commit comments