From 63b43f41254d144228fa8a1a8f229391ac0b9a9b 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. PR-URL: https://github.com/nodejs/node-addon-api/pull/837 Fixes: https://github.com/nodejs/node-addon-api/issues/834 Reviewed-By: Michael Dawson --- test/objectwrap_worker_thread.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/objectwrap_worker_thread.js b/test/objectwrap_worker_thread.js index 348309976..5e5e50b7e 100644 --- a/test/objectwrap_worker_thread.js +++ b/test/objectwrap_worker_thread.js @@ -1,14 +1,15 @@ '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`)); }