0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/addons/dlopen-ping-pong/test-worker.js
Jeremy Apthorp 4f434187ff
src: add file name to 'Module did not self-register' error
PR-URL: https://github.com/nodejs/node/pull/30125
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-11-19 16:03:55 +01:00

22 lines
711 B
JavaScript

'use strict';
const common = require('../../common');
if (common.isWindows)
common.skip('dlopen global symbol loading is not supported on this os.');
const assert = require('assert');
const { Worker } = require('worker_threads');
// Check that modules that are not declared as context-aware cannot be re-loaded
// from workers.
const bindingPath = require.resolve(`./build/${common.buildType}/binding`);
require(bindingPath);
new Worker(`require(${JSON.stringify(bindingPath)})`, { eval: true })
.on('error', common.mustCall((err) => {
assert.strictEqual(err.constructor, Error);
assert.strictEqual(err.message,
`Module did not self-register: '${bindingPath}'.`);
}));