Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve UV_THREADPOOL_SIZE tests on .env #49213

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/fixtures/dotenv/uv-threadpool.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UV_THREADPOOL_SIZE=4
31 changes: 31 additions & 0 deletions test/node-api/test_uv_threadpool_size/node-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'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
let filePath = path.join(__dirname, `./build/${common.buildType}/test_uv_threadpool_size`);
if (common.isWindows) {
filePath = filePath.replaceAll('\\', '\\\\');
}
const code = `
const { test } = require('${filePath}');
anonrig marked this conversation as resolved.
Show resolved Hide resolved
const size = parseInt(process.env.UV_THREADPOOL_SIZE, 10);
require('assert').strictEqual(size, 4);
test(size);
anonrig marked this conversation as resolved.
Show resolved Hide resolved
`.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);
13 changes: 0 additions & 13 deletions test/parallel/test-dotenv-node-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,4 @@ describe('.env supports NODE_OPTIONS', () => {
assert.strictEqual(child.code, 0);
});

it('should update UV_THREADPOOL_SIZE', async () => {
const code = `
require('assert').strictEqual(process.env.UV_THREADPOOL_SIZE, '5')
`.trim();
const child = await common.spawnPromisified(
process.execPath,
[ `--env-file=${relativePath}`, '--eval', code ],
{ cwd: __dirname },
);
assert.strictEqual(child.stderr, '');
assert.strictEqual(child.code, 0);
});

});