Files
node/test/parallel/test-experimental-shared-value-conveyor.js
T
Junsoo Ha f7968e73ee test: use common/child_process spawnSync helpers
Replace manual spawnSync() result assertions
with test/common/child_process helper functions.

Signed-off-by: Junsoo Ha <junsoo2018@naver.com>
PR-URL: https://github.com/nodejs/node/pull/65377
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-08-21 13:40:07 +00:00

39 lines
1.2 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker, parentPort } = require('worker_threads');
const { spawnSyncAndAssert } = require('../common/child_process');
if (process.env.TEST_CHILD_PROCESS === '1') {
// Do not use isMainThread so that this test itself can be run inside a Worker.
if (!process.env.HAS_STARTED_WORKER) {
process.env.HAS_STARTED_WORKER = 1;
const m = new globalThis.SharedArray(16);
const worker = new Worker(__filename);
worker.once('message', common.mustCall((message) => {
assert.strictEqual(message, m);
}));
worker.postMessage(m);
} else {
parentPort.once('message', common.mustCall((message) => {
// Simple echo.
parentPort.postMessage(message);
}));
}
} else {
if (process.config.variables.v8_enable_pointer_compression === 1) {
common.skip('--harmony-struct cannot be used with pointer compression');
}
const args = ['--harmony-struct', __filename];
const options = { env: { TEST_CHILD_PROCESS: '1', ...process.env } };
spawnSyncAndAssert(process.execPath, args, options, {
stdout: '',
stderr: '',
trim: true
});
}