Skip to content

Commit 6aeeaa7

Browse files
aduh95ruyadorno
authored andcommitted
test: fix addons and node-api test assumptions
PR-URL: #55441 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 73ab14f commit 6aeeaa7

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

test/addons/repl-domain-abort/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ process.on('exit', () => {
3838

3939
const lines = [
4040
// This line shouldn't cause an assertion error.
41-
`require('${buildPath}')` +
41+
`require(${JSON.stringify(buildPath)})` +
4242
// Log output to double check callback ran.
4343
'.method(function(v1, v2) {' +
4444
'console.log(\'cb_ran\'); return v1 === true && v2 === false; });',

test/node-api/test_instance_data/test.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,8 @@ if (module !== require.main) {
3838
function testProcessExit(addonName) {
3939
// Make sure that process exit is clean when the instance data has
4040
// references to JS objects.
41-
const path = require
42-
.resolve(`./build/${common.buildType}/${addonName}`)
43-
// Replace any backslashes with double backslashes because they'll be re-
44-
// interpreted back to single backslashes in the command line argument
45-
// to the child process. Windows needs this.
46-
.replace(/\\/g, '\\\\');
47-
const child = spawnSync(process.execPath, ['-e', `require('${path}');`]);
41+
const path = require.resolve(`./build/${common.buildType}/${addonName}`);
42+
const child = spawnSync(process.execPath, ['-e', `require(${JSON.stringify(path)});`]);
4843
assert.strictEqual(child.signal, null);
4944
assert.strictEqual(child.status, 0);
5045
assert.strictEqual(child.stderr.toString(), 'addon_free');

test/node-api/test_uv_threadpool_size/node-options.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ if (process.config.variables.node_without_node_options) {
1212
const uvThreadPoolPath = '../../fixtures/dotenv/uv-threadpool.env';
1313

1414
// Should update UV_THREADPOOL_SIZE
15-
let filePath = path.join(__dirname, `./build/${common.buildType}/test_uv_threadpool_size`);
16-
if (common.isWindows) {
17-
filePath = filePath.replaceAll('\\', '\\\\');
18-
}
15+
const filePath = path.join(__dirname, `./build/${common.buildType}/test_uv_threadpool_size`);
1916
const code = `
20-
const { test } = require('${filePath}');
17+
const { test } = require(${JSON.stringify(filePath)});
2118
const size = parseInt(process.env.UV_THREADPOOL_SIZE, 10);
2219
require('assert').strictEqual(size, 4);
2320
test(size);

0 commit comments

Comments
 (0)