@@ -42,11 +42,7 @@ let testModules = [
4242 'object/set_property' ,
4343 'promise' ,
4444 'run_script' ,
45- 'threadsafe_function_ex/call' ,
46- 'threadsafe_function_ex/context' ,
47- 'threadsafe_function_ex/example' ,
48- 'threadsafe_function_ex/simple' ,
49- 'threadsafe_function_ex/threadsafe' ,
45+ 'threadsafe_function_ex' ,
5046 'threadsafe_function/threadsafe_function_ctx' ,
5147 'threadsafe_function/threadsafe_function_existing_tsfn' ,
5248 'threadsafe_function/threadsafe_function_ptr' ,
@@ -79,10 +75,8 @@ if (napiVersion < 4) {
7975 testModules . splice ( testModules . indexOf ( 'threadsafe_function/threadsafe_function_sum' ) , 1 ) ;
8076 testModules . splice ( testModules . indexOf ( 'threadsafe_function/threadsafe_function_unref' ) , 1 ) ;
8177 testModules . splice ( testModules . indexOf ( 'threadsafe_function/threadsafe_function' ) , 1 ) ;
82- testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/call' ) , 1 ) ;
83- testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/context' ) , 1 ) ;
78+ testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/basic' ) , 1 ) ;
8479 testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/example' ) , 1 ) ;
85- testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/simple' ) , 1 ) ;
8680 testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/threadsafe' ) , 1 ) ;
8781}
8882
@@ -96,35 +90,41 @@ if (napiVersion < 6) {
9690 testModules . splice ( testModules . indexOf ( 'addon_data' ) , 1 ) ;
9791}
9892
99- if ( typeof global . gc === 'function' ) {
100- console . log ( `Testing with N-API Version '${ napiVersion } '.` ) ;
93+ async function run ( ) {
94+ if ( typeof global . gc === 'function' ) {
95+ console . log ( `Testing with N-API Version '${ napiVersion } '.` ) ;
10196
102- console . log ( 'Starting test suite\n' ) ;
97+ console . log ( 'Starting test suite\n' ) ;
10398
104- // Requiring each module runs tests in the module.
105- testModules . forEach ( name => {
106- console . log ( `Running test '${ name } '` ) ;
107- require ( './' + name ) ;
108- } ) ;
99+ // Requiring each module runs tests in the module.
100+ testModules . forEach ( name => {
101+ console . log ( `Running test '${ name } '` ) ;
102+ require ( './' + name ) ;
103+ } ) ;
109104
110- console . log ( '\nAll tests passed!' ) ;
111- } else {
112- // Construct the correct (version-dependent) command-line args.
113- let args = [ '--expose-gc' , '--no-concurrent-array-buffer-freeing' ] ;
114- if ( majorNodeVersion >= 14 ) {
115- args . push ( '--no-concurrent-array-buffer-sweeping' ) ;
116- }
117- args . push ( __filename ) ;
105+ console . log ( '\nAll tests passed!' ) ;
106+ } else {
107+ // Construct the correct (version-dependent) command-line args.
108+ let args = [ '--expose-gc' , '--no-concurrent-array-buffer-freeing' ] ;
109+ if ( majorNodeVersion >= 14 ) {
110+ args . push ( '--no-concurrent-array-buffer-sweeping' ) ;
111+ }
112+ args . push ( __filename ) ;
118113
119- const child = require ( './napi_child' ) . spawnSync ( process . argv [ 0 ] , args , {
120- stdio : 'inherit' ,
121- } ) ;
114+ const child = require ( './napi_child' ) . spawnSync ( process . argv [ 0 ] , args , {
115+ stdio : 'inherit' ,
116+ } ) ;
122117
123- if ( child . signal ) {
124- console . error ( `Tests aborted with ${ child . signal } ` ) ;
125- process . exitCode = 1 ;
126- } else {
127- process . exitCode = child . status ;
118+ if ( child . signal ) {
119+ console . error ( `Tests aborted with ${ child . signal } ` ) ;
120+ process . exitCode = 1 ;
121+ } else {
122+ process . exitCode = child . status ;
123+ }
124+ process . exit ( process . exitCode ) ;
128125 }
129- process . exit ( process . exitCode ) ;
130126}
127+
128+ run ( )
129+ . catch ( e => ( console . error ( e ) , process . exit ( 1 ) ) ) ;
130+
0 commit comments