node/test/parallel/test-no-addons-resolution-condition.js
Dominic Elm a9dd03b1ec src: add option to disable loading native addons
PR-URL: https://github.com/nodejs/node/pull/39977
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-09-10 10:54:39 -05:00

30 lines
824 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const { Worker, isMainThread, parentPort } = require('worker_threads');
const assert = require('assert');
const { createRequire } = require('module');
const loadFixture = createRequire(fixtures.path('node_modules'));
if (isMainThread) {
const tests = [[], ['--no-addons']];
for (const execArgv of tests) {
const worker = new Worker(__filename, { execArgv });
worker.on('message', common.mustCall((message) => {
if (execArgv.length === 0) {
assert.strictEqual(message, 'using native addons');
} else {
assert.strictEqual(message, 'not using native addons');
}
}));
}
} else {
const message = loadFixture('pkgexports/no-addons');
parentPort.postMessage(message);
}