Skip to content

Commit

Permalink
test: improve UV_THREADPOOL_SIZE tests on .env
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Aug 29, 2023
1 parent 0ebd088 commit 7487b8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion test/fixtures/dotenv/node-options.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CUSTOM_VARIABLE=hello-world
NODE_NO_WARNINGS=1
NODE_OPTIONS="--experimental-permission --allow-fs-read=*"
TZ=Pacific/Honolulu
UV_THREADPOOL_SIZE=5
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=5
15 changes: 9 additions & 6 deletions test/parallel/test-dotenv-node-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if (process.config.variables.node_without_node_options) {
common.skip('missing NODE_OPTIONS support');
}

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

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

Expand All @@ -18,7 +19,7 @@ describe('.env supports NODE_OPTIONS', () => {
`.trim();
const child = await common.spawnPromisified(
process.execPath,
[ `--env-file=${relativePath}`, '--eval', code ],
[ `--env-file=${nodeOptionsPath}`, '--eval', code ],
{ cwd: __dirname },
);
// NODE_NO_WARNINGS is set, so `stderr` should not contain
Expand All @@ -35,7 +36,7 @@ describe('.env supports NODE_OPTIONS', () => {
`.trim();
const child = await common.spawnPromisified(
process.execPath,
[ `--env-file=${relativePath}`, '--eval', code ],
[ `--env-file=${nodeOptionsPath}`, '--eval', code ],
{ cwd: __dirname },
);
assert.match(child.stderr, /Error: Access to this API has been restricted/);
Expand All @@ -50,7 +51,7 @@ describe('.env supports NODE_OPTIONS', () => {
`.trim();
const child = await common.spawnPromisified(
process.execPath,
[ `--env-file=${relativePath}`, '--eval', code ],
[ `--env-file=${nodeOptionsPath}`, '--eval', code ],
{ cwd: __dirname },
);
assert.strictEqual(child.stderr, '');
Expand All @@ -59,11 +60,13 @@ describe('.env supports NODE_OPTIONS', () => {

it('should update UV_THREADPOOL_SIZE', async () => {
const code = `
require('assert').strictEqual(process.env.UV_THREADPOOL_SIZE, '5')
const { test } = require('../node-api/test_uv_threadpool_size/build/${common.buildType}/test_uv_threadpool_size');
const size = parseInt(process.env.UV_THREADPOOL_SIZE || 4, 10);
test(size);
`.trim();
const child = await common.spawnPromisified(
process.execPath,
[ `--env-file=${relativePath}`, '--eval', code ],
[ `--env-file=${uvThreadPoolPath}`, '--eval', code ],
{ cwd: __dirname },
);
assert.strictEqual(child.stderr, '');
Expand Down

0 comments on commit 7487b8d

Please sign in to comment.