@@ -42,11 +42,7 @@ let testModules = [
42
42
'object/set_property' ,
43
43
'promise' ,
44
44
'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' ,
50
46
'threadsafe_function/threadsafe_function_ctx' ,
51
47
'threadsafe_function/threadsafe_function_existing_tsfn' ,
52
48
'threadsafe_function/threadsafe_function_ptr' ,
@@ -79,10 +75,8 @@ if (napiVersion < 4) {
79
75
testModules . splice ( testModules . indexOf ( 'threadsafe_function/threadsafe_function_sum' ) , 1 ) ;
80
76
testModules . splice ( testModules . indexOf ( 'threadsafe_function/threadsafe_function_unref' ) , 1 ) ;
81
77
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 ) ;
84
79
testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/example' ) , 1 ) ;
85
- testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/simple' ) , 1 ) ;
86
80
testModules . splice ( testModules . indexOf ( 'threadsafe_function_ex/threadsafe' ) , 1 ) ;
87
81
}
88
82
@@ -96,35 +90,41 @@ if (napiVersion < 6) {
96
90
testModules . splice ( testModules . indexOf ( 'addon_data' ) , 1 ) ;
97
91
}
98
92
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 } '.` ) ;
101
96
102
- console . log ( 'Starting test suite\n' ) ;
97
+ console . log ( 'Starting test suite\n' ) ;
103
98
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
+ } ) ;
109
104
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 ) ;
118
113
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
+ } ) ;
122
117
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 ) ;
128
125
}
129
- process . exit ( process . exitCode ) ;
130
126
}
127
+
128
+ run ( )
129
+ . catch ( e => ( console . error ( e ) , process . exit ( 1 ) ) ) ;
130
+
0 commit comments