From 7b7c6e0d511d29ed24cfd208ca7277a0786aeccf Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 17 Aug 2023 10:18:53 -0400 Subject: [PATCH] test: improve `UV_THREADPOOL_SIZE` tests on `.env` --- test/fixtures/dotenv/node-options.env | 1 - test/fixtures/dotenv/uv-threadpool.env | 1 + test/parallel/test-dotenv-node-options.js | 15 +++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 test/fixtures/dotenv/uv-threadpool.env diff --git a/test/fixtures/dotenv/node-options.env b/test/fixtures/dotenv/node-options.env index 3dc9b529947c30..51494473d5aa81 100644 --- a/test/fixtures/dotenv/node-options.env +++ b/test/fixtures/dotenv/node-options.env @@ -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 diff --git a/test/fixtures/dotenv/uv-threadpool.env b/test/fixtures/dotenv/uv-threadpool.env new file mode 100644 index 00000000000000..1a012213bd01ff --- /dev/null +++ b/test/fixtures/dotenv/uv-threadpool.env @@ -0,0 +1 @@ +UV_THREADPOOL_SIZE=5 diff --git a/test/parallel/test-dotenv-node-options.js b/test/parallel/test-dotenv-node-options.js index 4b35f22f395371..8a760c6a75b0c4 100644 --- a/test/parallel/test-dotenv-node-options.js +++ b/test/parallel/test-dotenv-node-options.js @@ -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', () => { @@ -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 @@ -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/); @@ -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, ''); @@ -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, '');