@@ -23,74 +23,51 @@ if (typeof global.gc !== 'function') {
23
23
process . exit ( process . exitCode ) ;
24
24
}
25
25
26
+ const fs = require ( 'fs' ) ;
27
+ const path = require ( 'path' ) ;
28
+
29
+ let testModules = [ ] ;
30
+
31
+ // TODO(RaisinTen): Update this when the test filenames
32
+ // are changed into test_*.js.
33
+ function loadTestModules ( currentDirectory = __dirname , pre = '' ) {
34
+ fs . readdirSync ( currentDirectory ) . forEach ( ( file ) => {
35
+ if ( currentDirectory === __dirname && (
36
+ file === 'binding.cc' ||
37
+ file === 'binding.gyp' ||
38
+ file === 'build' ||
39
+ file === 'common' ||
40
+ file === 'napi_child.js' ||
41
+ file === 'testUtil.js' ||
42
+ file === 'thunking_manual.cc' ||
43
+ file === 'thunking_manual.js' ||
44
+ file === 'index.js' ||
45
+ file [ 0 ] === '.' ) ) {
46
+ return ;
47
+ }
48
+ const absoluteFilepath = path . join ( currentDirectory , file ) ;
49
+ if ( fs . statSync ( absoluteFilepath ) . isDirectory ( ) ) {
50
+ if ( fs . existsSync ( absoluteFilepath + '/index.js' ) ) {
51
+ testModules . push ( pre + file ) ;
52
+ } else {
53
+ loadTestModules ( absoluteFilepath , pre + file + '/' ) ;
54
+ }
55
+ } else {
56
+ const parsedFilepath = path . parse ( file ) ;
57
+ if ( parsedFilepath . ext === '.js' ) {
58
+ testModules . push ( pre + parsedFilepath . name ) ;
59
+ }
60
+ }
61
+ } ) ;
62
+ }
63
+
64
+ loadTestModules ( ) ;
65
+
26
66
process . config . target_defaults . default_configuration =
27
- require ( 'fs' )
28
- . readdirSync ( require ( ' path' ) . join ( __dirname , 'build' ) )
67
+ fs
68
+ . readdirSync ( path . join ( __dirname , 'build' ) )
29
69
. filter ( ( item ) => ( item === 'Debug' || item === 'Release' ) ) [ 0 ] ;
30
70
31
- // FIXME: We might need a way to load test modules automatically without
32
- // explicit declaration as follows.
33
- let testModules = [
34
- 'addon_build' ,
35
- 'addon' ,
36
- 'addon_data' ,
37
- 'arraybuffer' ,
38
- 'asynccontext' ,
39
- 'asyncprogressqueueworker' ,
40
- 'asyncprogressworker' ,
41
- 'asyncworker' ,
42
- 'asyncworker-nocallback' ,
43
- 'asyncworker-persistent' ,
44
- 'basic_types/array' ,
45
- 'basic_types/boolean' ,
46
- 'basic_types/number' ,
47
- 'basic_types/value' ,
48
- 'bigint' ,
49
- 'date' ,
50
- 'buffer' ,
51
- 'callbackscope' ,
52
- 'dataview/dataview' ,
53
- 'dataview/dataview_read_write' ,
54
- 'error' ,
55
- 'external' ,
56
- 'function' ,
57
- 'handlescope' ,
58
- 'memory_management' ,
59
- 'name' ,
60
- 'object/delete_property' ,
61
- 'object/finalizer' ,
62
- 'object/get_property' ,
63
- 'object/has_own_property' ,
64
- 'object/has_property' ,
65
- 'object/object' ,
66
- 'object/object_deprecated' ,
67
- 'object/set_property' ,
68
- 'promise' ,
69
- 'run_script' ,
70
- 'threadsafe_function/threadsafe_function_ctx' ,
71
- 'threadsafe_function/threadsafe_function_existing_tsfn' ,
72
- 'threadsafe_function/threadsafe_function_ptr' ,
73
- 'threadsafe_function/threadsafe_function_sum' ,
74
- 'threadsafe_function/threadsafe_function_unref' ,
75
- 'threadsafe_function/threadsafe_function' ,
76
- 'typed_threadsafe_function/typed_threadsafe_function_ctx' ,
77
- 'typed_threadsafe_function/typed_threadsafe_function_existing_tsfn' ,
78
- 'typed_threadsafe_function/typed_threadsafe_function_ptr' ,
79
- 'typed_threadsafe_function/typed_threadsafe_function_sum' ,
80
- 'typed_threadsafe_function/typed_threadsafe_function_unref' ,
81
- 'typed_threadsafe_function/typed_threadsafe_function' ,
82
- 'typedarray' ,
83
- 'typedarray-bigint' ,
84
- 'objectwrap' ,
85
- 'objectwrap_constructor_exception' ,
86
- 'objectwrap-removewrap' ,
87
- 'objectwrap_multiple_inheritance' ,
88
- 'objectwrap_worker_thread' ,
89
- 'objectreference' ,
90
- 'reference' ,
91
- 'version_management'
92
- ] ;
93
-
94
71
let napiVersion = Number ( process . versions . napi ) ;
95
72
if ( process . env . NAPI_VERSION ) {
96
73
// we need this so that we don't try run tests that rely
0 commit comments