Skip to content

Commit

Permalink
test: fix buildType bug objectwrap_worker_thread
Browse files Browse the repository at this point in the history
Since worker threads inherit non-process-specific options by
default, the configuration needs to be shared via workerData.

PR-URL: nodejs/node-addon-api#837
Fixes: nodejs/node-addon-api#834
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
kevindavies8 committed Nov 23, 2020
1 parent 7e28910 commit c1f0837
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/objectwrap_worker_thread.js
Original file line number Diff line number Diff line change
@@ -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`));
}

0 comments on commit c1f0837

Please sign in to comment.