Skip to content

Commit 89d2dea

Browse files
committed
test: wip with tsfnex tests
1 parent 6706f96 commit 89d2dea

File tree

19 files changed

+982
-727
lines changed

19 files changed

+982
-727
lines changed

test/binding.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ Object InitThreadSafeFunctionPtr(Env env);
4848
Object InitThreadSafeFunctionSum(Env env);
4949
Object InitThreadSafeFunctionUnref(Env env);
5050
Object InitThreadSafeFunction(Env env);
51-
Object InitThreadSafeFunctionExCall(Env env);
52-
Object InitThreadSafeFunctionExContext(Env env);
51+
Object InitThreadSafeFunctionExBasic(Env env);
5352
Object InitThreadSafeFunctionExExample(Env env);
54-
Object InitThreadSafeFunctionExSimple(Env env);
5553
Object InitThreadSafeFunctionExThreadSafe(Env env);
5654
#endif
5755
Object InitTypedArray(Env env);
@@ -110,10 +108,8 @@ Object Init(Env env, Object exports) {
110108
exports.Set("threadsafe_function_sum", InitThreadSafeFunctionSum(env));
111109
exports.Set("threadsafe_function_unref", InitThreadSafeFunctionUnref(env));
112110
exports.Set("threadsafe_function", InitThreadSafeFunction(env));
113-
exports.Set("threadsafe_function_ex_call", InitThreadSafeFunctionExCall(env));
114-
exports.Set("threadsafe_function_ex_context", InitThreadSafeFunctionExContext(env));
111+
exports.Set("threadsafe_function_ex_basic", InitThreadSafeFunctionExBasic(env));
115112
exports.Set("threadsafe_function_ex_example", InitThreadSafeFunctionExExample(env));
116-
exports.Set("threadsafe_function_ex_simple", InitThreadSafeFunctionExSimple(env));
117113
exports.Set("threadsafe_function_ex_threadsafe", InitThreadSafeFunctionExThreadSafe(env));
118114
#endif
119115
exports.Set("typedarray", InitTypedArray(env));

test/binding.gyp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535
'object/set_property.cc',
3636
'promise.cc',
3737
'run_script.cc',
38-
'threadsafe_function_ex/call.cc',
39-
'threadsafe_function_ex/context.cc',
38+
'threadsafe_function_ex/basic.cc',
4039
'threadsafe_function_ex/example.cc',
41-
'threadsafe_function_ex/simple.cc',
4240
'threadsafe_function_ex/threadsafe.cc',
4341
'threadsafe_function/threadsafe_function_ctx.cc',
4442
'threadsafe_function/threadsafe_function_existing_tsfn.cc',

test/index.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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+

test/threadsafe_function_ex/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Napi::ThreadSafeFunctionEx tests
2+
3+
|Spec|Test|Native|Node|Description|
4+
|----|---|---|---|---|
5+
|call

test/threadsafe_function_ex/call.cc

Lines changed: 0 additions & 88 deletions
This file was deleted.

test/threadsafe_function_ex/call.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/threadsafe_function_ex/context.cc

Lines changed: 0 additions & 101 deletions
This file was deleted.

test/threadsafe_function_ex/context.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)