node/test/parallel/test-worker-cleanexit-with-moduleload.js
Daniel Bevenius d6a32cfe7c test: add hasCrypto to worker-cleanexit-with-moduleload
Currently, this test fails when configured --without-ssl:

=== release test-worker-cleanexit-with-moduleload ===
Path: parallel/test-worker-cleanexit-with-moduleload
events.js:173
      throw er; // Unhandled 'error' event
      ^
internal/util.js:101
    throw new ERR_NO_CRYPTO();
    ^

Error [ERR_NO_CRYPTO]:
Node.js is not compiled with OpenSSL crypto support

This commit as a check for crypto so that this test is skipped if there
is no crypto support.

PR-URL: https://github.com/nodejs/node/pull/25811
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-02-04 05:36:39 +01:00

30 lines
862 B
JavaScript

'use strict';
const common = require('../common');
// Harden the thread interactions on the exit path.
// Ensure workers are able to bail out safe at
// arbitrary execution points. By using a number of
// internal modules as load candidates, the expectation
// is that those will be at various control flow points
// preferrably in the C++ land.
const { Worker } = require('worker_threads');
const modules = [ 'fs', 'assert', 'async_hooks', 'buffer', 'child_process',
'net', 'http', 'os', 'path', 'v8', 'vm'
];
if (common.hasCrypto) {
modules.push('https');
}
for (let i = 0; i < 10; i++) {
new Worker(`const modules = [${modules.map((m) => `'${m}'`)}];` +
'modules.forEach((module) => {' +
'const m = require(module);' +
'});', { eval: true });
}
// Allow workers to go live.
setTimeout(() => {
process.exit(0);
}, 200);