1import { mustCall } from '../common/index.mjs';
2import { Worker, isMainThread } from 'worker_threads';
3import assert from 'assert';
4import { fileURLToPath } from 'url';
5import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
6
7if (isMainThread) {
8  const tests = [[], ['--no-addons']];
9
10  for (const execArgv of tests) {
11    new Worker(fileURLToPath(import.meta.url), { execArgv });
12  }
13} else {
14  [requireFixture, importFixture].forEach((loadFixture) => {
15    loadFixture('pkgexports/no-addons').then(
16      mustCall((module) => {
17        const message = module.default;
18
19        if (process.execArgv.length === 0) {
20          assert.strictEqual(message, 'using native addons');
21        } else {
22          assert.strictEqual(message, 'not using native addons');
23        }
24      })
25    );
26  });
27}
28