Skip to content

Commit 7b7c6e0

Browse files
committed
test: improve UV_THREADPOOL_SIZE tests on .env
1 parent 769823e commit 7b7c6e0

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

test/fixtures/dotenv/node-options.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ CUSTOM_VARIABLE=hello-world
22
NODE_NO_WARNINGS=1
33
NODE_OPTIONS="--experimental-permission --allow-fs-read=*"
44
TZ=Pacific/Honolulu
5-
UV_THREADPOOL_SIZE=5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UV_THREADPOOL_SIZE=5

test/parallel/test-dotenv-node-options.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if (process.config.variables.node_without_node_options) {
88
common.skip('missing NODE_OPTIONS support');
99
}
1010

11-
const relativePath = '../fixtures/dotenv/node-options.env';
11+
const nodeOptionsPath = '../fixtures/dotenv/node-options.env';
12+
const uvThreadPoolPath = '../fixtures/dotenv/uv-threadpool.env';
1213

1314
describe('.env supports NODE_OPTIONS', () => {
1415

@@ -18,7 +19,7 @@ describe('.env supports NODE_OPTIONS', () => {
1819
`.trim();
1920
const child = await common.spawnPromisified(
2021
process.execPath,
21-
[ `--env-file=${relativePath}`, '--eval', code ],
22+
[ `--env-file=${nodeOptionsPath}`, '--eval', code ],
2223
{ cwd: __dirname },
2324
);
2425
// NODE_NO_WARNINGS is set, so `stderr` should not contain
@@ -35,7 +36,7 @@ describe('.env supports NODE_OPTIONS', () => {
3536
`.trim();
3637
const child = await common.spawnPromisified(
3738
process.execPath,
38-
[ `--env-file=${relativePath}`, '--eval', code ],
39+
[ `--env-file=${nodeOptionsPath}`, '--eval', code ],
3940
{ cwd: __dirname },
4041
);
4142
assert.match(child.stderr, /Error: Access to this API has been restricted/);
@@ -50,7 +51,7 @@ describe('.env supports NODE_OPTIONS', () => {
5051
`.trim();
5152
const child = await common.spawnPromisified(
5253
process.execPath,
53-
[ `--env-file=${relativePath}`, '--eval', code ],
54+
[ `--env-file=${nodeOptionsPath}`, '--eval', code ],
5455
{ cwd: __dirname },
5556
);
5657
assert.strictEqual(child.stderr, '');
@@ -59,11 +60,13 @@ describe('.env supports NODE_OPTIONS', () => {
5960

6061
it('should update UV_THREADPOOL_SIZE', async () => {
6162
const code = `
62-
require('assert').strictEqual(process.env.UV_THREADPOOL_SIZE, '5')
63+
const { test } = require('../node-api/test_uv_threadpool_size/build/${common.buildType}/test_uv_threadpool_size');
64+
const size = parseInt(process.env.UV_THREADPOOL_SIZE || 4, 10);
65+
test(size);
6366
`.trim();
6467
const child = await common.spawnPromisified(
6568
process.execPath,
66-
[ `--env-file=${relativePath}`, '--eval', code ],
69+
[ `--env-file=${uvThreadPoolPath}`, '--eval', code ],
6770
{ cwd: __dirname },
6871
);
6972
assert.strictEqual(child.stderr, '');

0 commit comments

Comments
 (0)