From 7566ac4d7d9dbfb923457bbd469d5281de68d27f Mon Sep 17 00:00:00 2001 From: raisinten Date: Thu, 19 Nov 2020 18:09:47 +0530 Subject: [PATCH] test: fix buildType bug objectwrap_worker_thread Since worker threads inherit non-process-specific options by default, the configuration needs to be shared via workerData. Fixes: https://github.com/nodejs/node-addon-api/issues/834 --- test/objectwrap_worker_thread.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/objectwrap_worker_thread.js b/test/objectwrap_worker_thread.js index 348309976..0e416153f 100644 --- a/test/objectwrap_worker_thread.js +++ b/test/objectwrap_worker_thread.js @@ -1,14 +1,16 @@ 'use strict'; -const buildType = process.config.target_defaults.default_configuration; -const { Worker, isMainThread } = require('worker_threads'); +const { Worker, isMainThread, workerData } = require('worker_threads'); if (isMainThread) { - new Worker(__filename); + const buildType = process.config.target_defaults.default_configuration; + new Worker(__filename, { workerData: buildType }); } else { const test = binding => { new binding.objectwrap.Test(); }; + const buildType = workerData; test(require(`./build/${buildType}/binding.node`)); test(require(`./build/${buildType}/binding_noexcept.node`)); } +