node/test/node-api/test_uv_threadpool_size/node-options.js
Antoine du Hamel 47ad609d64
test: fix addons and node-api test assumptions
PR-URL: https://github.com/nodejs/node/pull/55441
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2024-10-22 07:49:19 +00:00

29 lines
899 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
const path = require('path');
const { spawnSync } = require('child_process');
if (process.config.variables.node_without_node_options) {
common.skip('missing NODE_OPTIONS support');
}
const uvThreadPoolPath = '../../fixtures/dotenv/uv-threadpool.env';
// Should update UV_THREADPOOL_SIZE
const filePath = path.join(__dirname, `./build/${common.buildType}/test_uv_threadpool_size`);
const code = `
const { test } = require(${JSON.stringify(filePath)});
const size = parseInt(process.env.UV_THREADPOOL_SIZE, 10);
require('assert').strictEqual(size, 4);
test(size);
`.trim();
const child = spawnSync(
process.execPath,
[ `--env-file=${uvThreadPoolPath}`, '--eval', code ],
{ cwd: __dirname, encoding: 'utf-8' },
);
assert.strictEqual(child.stderr, '');
assert.strictEqual(child.status, 0);