Skip to content

Commit

Permalink
fixup! 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 7487b8d commit e24414c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
33 changes: 33 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,33 @@
'use strict';

const common = require('../../common');
const assert = require('node:assert');
const path = require('node:path');
const { describe, it } = require('node:test');

if (process.config.variables.node_without_node_options) {
common.skip('missing NODE_OPTIONS support');
}

const uvThreadPoolPath = '../../fixtures/dotenv/uv-threadpool.env';

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

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

});
16 changes: 0 additions & 16 deletions test/parallel/test-dotenv-node-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if (process.config.variables.node_without_node_options) {
}

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

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

Expand Down Expand Up @@ -58,19 +57,4 @@ describe('.env supports NODE_OPTIONS', () => {
assert.strictEqual(child.code, 0);
});

it('should update UV_THREADPOOL_SIZE', async () => {
const code = `
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=${uvThreadPoolPath}`, '--eval', code ],
{ cwd: __dirname },
);
assert.strictEqual(child.stderr, '');
assert.strictEqual(child.code, 0);
});

});

0 comments on commit e24414c

Please sign in to comment.