diff --git a/test/common/index.js b/test/common/index.js index ab6d12b..e8c480c 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -101,3 +101,10 @@ exports.runTestWithBindingPath = async function(test, buildType) { await test(item); } } + +exports.runTestWithBuildType = async function(test, buildType) { + buildType = buildType || process.config.target_defaults.default_configuration || 'Release'; + + await Promise.resolve(test(buildType)) + .finally(exports.mustCall()); +} diff --git a/test/objectwrap_worker_thread.js b/test/objectwrap_worker_thread.js index eedc9ee..e5cfdb8 100644 --- a/test/objectwrap_worker_thread.js +++ b/test/objectwrap_worker_thread.js @@ -1,14 +1,19 @@ 'use strict'; +const path = require('path'); const { Worker, isMainThread, workerData } = require('worker_threads'); -if (isMainThread) { - const buildType = process.config.target_defaults.default_configuration; - new Worker(__filename, { workerData: buildType }); -} else { - const test = binding => { - new binding.objectwrap.Test(); - }; +module.exports = require('./common').runTestWithBuildType(test); - const buildType = workerData; - require('./common').runTest(test, buildType); +async function test(buildType) { + if (isMainThread) { + const buildType = process.config.target_defaults.default_configuration; + const worker = new Worker(__filename, { workerData: buildType }); + return new Promise((resolve, reject) => { + worker.on('exit', () => { + resolve(); + }); + }, () => {}); + } else { + await require(path.join(__dirname, 'objectwrap.js')); + } } diff --git a/test/symbol.js b/test/symbol.js index 171f81e..7601feb 100644 --- a/test/symbol.js +++ b/test/symbol.js @@ -3,14 +3,17 @@ const buildType = process.config.target_defaults.default_configuration; const assert = require('assert'); -test(require(`./build/${buildType}/binding.node`)); -test(require(`./build/${buildType}/binding_noexcept.node`)); +module.exports = require('./common').runTest(test); -async function test(binding) +function test(binding) { + const majorNodeVersion = process.versions.node.split('.')[0]; - const wellKnownSymbolFunctions = ['asyncIterator','hasInstance','isConcatSpreadable', 'iterator','match','matchAll','replace','search','split','species','toPrimitive','toStringTag','unscopables']; + let wellKnownSymbolFunctions = ['asyncIterator','hasInstance','isConcatSpreadable', 'iterator','match','replace','search','split','species','toPrimitive','toStringTag','unscopables']; + if (majorNodeVersion >= 12) { + wellKnownSymbolFunctions.push('matchAll'); + } function assertCanCreateSymbol(symbol) {