From d0a22f912faa8c272575e0baadf5733de7bbbea8 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 27 Feb 2026 12:18:42 +0100 Subject: [PATCH 1/4] test: remove unnecessary `process.exit` calls from test files --- benchmark/buffers/buffer-transcode.js | 6 ++---- ...ocess-fork-advanced-header-serialization.js | 6 ++---- test/parallel/test-child-process-internal.js | 3 --- test/parallel/test-child-process-silent.js | 6 ++---- .../test-child-process-spawnsync-input.js | 1 - .../test-child-process-stdout-flush-exit.js | 1 - test/parallel/test-cli-eval.js | 2 +- .../test-inspector-port-zero-cluster.js | 2 -- test/parallel/test-net-listen-twice.js | 2 +- .../test-permission-allow-child-process-cli.js | 2 +- .../test-permission-allow-worker-cli.js | 2 +- .../test-permission-child-process-cli.js | 2 +- test/parallel/test-process-env.js | 2 +- .../test-runner-run-files-undefined.mjs | 3 +-- test/parallel/test-trace-exit.js | 18 +++++++----------- test/parallel/test-worker-safe-getters.js | 2 -- .../test-worker-stdio-flush-inflight.js | 1 - test/parallel/test-worker-thread-name.js | 1 - 18 files changed, 20 insertions(+), 42 deletions(-) diff --git a/benchmark/buffers/buffer-transcode.js b/benchmark/buffers/buffer-transcode.js index cbb3b2e9b16374..abdb06d042d66e 100644 --- a/benchmark/buffers/buffer-transcode.js +++ b/benchmark/buffers/buffer-transcode.js @@ -3,12 +3,10 @@ const common = require('../common.js'); const assert = require('node:assert'); const buffer = require('node:buffer'); -const hasIntl = !!process.config.variables.v8_enable_i18n_support; const encodings = ['latin1', 'ascii', 'ucs2', 'utf8']; -if (!hasIntl) { - console.log('Skipping: `transcode` is only available on platforms that support i18n`'); - process.exit(0); +if (!common.hasIntl) { + common.skip('`transcode` is only available on platforms that support i18n`'); } const bench = common.createBenchmark(main, { diff --git a/test/parallel/test-child-process-fork-advanced-header-serialization.js b/test/parallel/test-child-process-fork-advanced-header-serialization.js index 27c15649e732d6..85116a1b5d16e0 100644 --- a/test/parallel/test-child-process-fork-advanced-header-serialization.js +++ b/test/parallel/test-child-process-fork-advanced-header-serialization.js @@ -13,11 +13,9 @@ if (process.argv[2] === 'child-buffer') { v & 0xFF, ]); const fd = process.channel?.fd; - if (fd === undefined) { - // skip test - process.exit(0); + if (fd !== undefined) { + fs.writeSync(fd, payload); } - fs.writeSync(fd, payload); return; } diff --git a/test/parallel/test-child-process-internal.js b/test/parallel/test-child-process-internal.js index c6ce0a8e04718c..345d4951742393 100644 --- a/test/parallel/test-child-process-internal.js +++ b/test/parallel/test-child-process-internal.js @@ -34,9 +34,6 @@ if (process.argv[2] === 'child') { // Send internal message process.send(internal); - - process.exit(0); - } else { const fork = require('child_process').fork; diff --git a/test/parallel/test-child-process-silent.js b/test/parallel/test-child-process-silent.js index 892c4527c9e2a2..3c0acf97555d0d 100644 --- a/test/parallel/test-child-process-silent.js +++ b/test/parallel/test-child-process-silent.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const childProcess = require('child_process'); @@ -44,9 +44,7 @@ if (process.argv[2] === 'pipe') { // Allow child process to self terminate child.disconnect(); - child.on('exit', function() { - process.exit(0); - }); + child.on('exit', common.mustCall()); } else { // Testcase | start primary && child IPC test diff --git a/test/parallel/test-child-process-spawnsync-input.js b/test/parallel/test-child-process-spawnsync-input.js index 62ae476ae17caa..f0c3d3d78978d0 100644 --- a/test/parallel/test-child-process-spawnsync-input.js +++ b/test/parallel/test-child-process-spawnsync-input.js @@ -65,7 +65,6 @@ if (process.argv.includes('spawnchild')) { checkSpawnSyncRet(ret); break; } - process.exit(0); return; } diff --git a/test/parallel/test-child-process-stdout-flush-exit.js b/test/parallel/test-child-process-stdout-flush-exit.js index 90f746c39ef6d3..4c5de7d9a2b42d 100644 --- a/test/parallel/test-child-process-stdout-flush-exit.js +++ b/test/parallel/test-child-process-stdout-flush-exit.js @@ -36,7 +36,6 @@ if (process.argv[2] === 'child') { console.log('filler'); } console.log('goodbye'); - process.exit(0); } else { // parent process const spawn = require('child_process').spawn; diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 8d765f10fbcbdb..2e5b3dc5992abc 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -35,7 +35,7 @@ const fixtures = require('../common/fixtures'); if (process.argv.length > 2) { console.log(process.argv.slice(2).join(' ')); - process.exit(0); + return; } // Assert that nothing is written to stdout. diff --git a/test/parallel/test-inspector-port-zero-cluster.js b/test/parallel/test-inspector-port-zero-cluster.js index 5ee7bcf7417345..79f245ed3e4150 100644 --- a/test/parallel/test-inspector-port-zero-cluster.js +++ b/test/parallel/test-inspector-port-zero-cluster.js @@ -50,6 +50,4 @@ if (cluster.isPrimary) { console.error(err); process.exit(1); }); -} else { - process.exit(0); } diff --git a/test/parallel/test-net-listen-twice.js b/test/parallel/test-net-listen-twice.js index 5a2399ea217005..281868da5a9eb7 100644 --- a/test/parallel/test-net-listen-twice.js +++ b/test/parallel/test-net-listen-twice.js @@ -19,7 +19,7 @@ if (cluster.isPrimary) { server.listen(); } catch (e) { console.error(e); - process.exit(0); + return; } let i = 0; process.on('internalMessage', (msg) => { diff --git a/test/parallel/test-permission-allow-child-process-cli.js b/test/parallel/test-permission-allow-child-process-cli.js index d82332ba3d5084..640a043d9f5d25 100644 --- a/test/parallel/test-permission-allow-child-process-cli.js +++ b/test/parallel/test-permission-allow-child-process-cli.js @@ -24,7 +24,7 @@ if (process.argv[2] === 'child') { code: 'ERR_ACCESS_DENIED', permission: 'FileSystemWrite', })); - process.exit(0); + return; } // Guarantee the initial state diff --git a/test/parallel/test-permission-allow-worker-cli.js b/test/parallel/test-permission-allow-worker-cli.js index 8ccbc5d4960885..228d1ea5607fc1 100644 --- a/test/parallel/test-permission-allow-worker-cli.js +++ b/test/parallel/test-permission-allow-worker-cli.js @@ -6,7 +6,7 @@ const assert = require('assert'); const { isMainThread, Worker } = require('worker_threads'); if (!isMainThread) { - process.exit(0); + return; } // Guarantee the initial state diff --git a/test/parallel/test-permission-child-process-cli.js b/test/parallel/test-permission-child-process-cli.js index abd4271257b6fa..3330bcddd96f9d 100644 --- a/test/parallel/test-permission-child-process-cli.js +++ b/test/parallel/test-permission-child-process-cli.js @@ -12,7 +12,7 @@ const assert = require('assert'); const childProcess = require('child_process'); if (process.argv[2] === 'child') { - process.exit(0); + return; } // Guarantee the initial state diff --git a/test/parallel/test-process-env.js b/test/parallel/test-process-env.js index bd2cd066fa2285..dd926a29527851 100644 --- a/test/parallel/test-process-env.js +++ b/test/parallel/test-process-env.js @@ -32,7 +32,7 @@ if (process.argv[2] === 'you-are-the-child') { assert.strictEqual(process.env[42], 'forty-two'); const has = Object.hasOwn(process.env, 'hasOwnProperty'); assert.strictEqual(has, true); - process.exit(0); + return; } { diff --git a/test/parallel/test-runner-run-files-undefined.mjs b/test/parallel/test-runner-run-files-undefined.mjs index 9d08b10a4550cd..d19063ef60512a 100644 --- a/test/parallel/test-runner-run-files-undefined.mjs +++ b/test/parallel/test-runner-run-files-undefined.mjs @@ -6,8 +6,7 @@ import { fork } from 'node:child_process'; import assert from 'node:assert'; if (common.hasCrypto) { - console.log('1..0 # Skipped: no crypto'); - process.exit(0); + common.skip('no crypto'); } if (process.env.CHILD === 'true') { diff --git a/test/parallel/test-trace-exit.js b/test/parallel/test-trace-exit.js index 7a4c222c40f74c..bfe412c5fba9c7 100644 --- a/test/parallel/test-trace-exit.js +++ b/test/parallel/test-trace-exit.js @@ -7,26 +7,22 @@ const { Worker, isMainThread, workerData } = require('worker_threads'); const variant = process.argv[process.argv.length - 1]; switch (true) { - case variant === 'main-thread': { - return; - } - case variant === 'main-thread-exit': { + case isMainThread ? variant === 'main-thread-exit' : workerData === 'worker-thread-exit': return process.exit(0); - } case variant.startsWith('worker-thread'): { const worker = new Worker(__filename, { workerData: variant }); worker.on('error', common.mustNotCall()); worker.on('exit', common.mustCall((code) => { assert.strictEqual(code, 0); })); - return; } - case !isMainThread: { - if (workerData === 'worker-thread-exit') { - process.exit(0); - } + // eslint-disable-next-line no-fallthrough + case variant === 'main-thread': + // eslint-disable-next-line no-fallthrough + case variant === 'main-thread-exit': + // eslint-disable-next-line no-fallthrough + case !isMainThread: return; - } } (async function() { diff --git a/test/parallel/test-worker-safe-getters.js b/test/parallel/test-worker-safe-getters.js index 69856659a5773b..a22f92b3354a4b 100644 --- a/test/parallel/test-worker-safe-getters.js +++ b/test/parallel/test-worker-safe-getters.js @@ -29,6 +29,4 @@ if (isMainThread) { assert.strictEqual(w.stdout, stdout); assert.strictEqual(w.stderr, stderr); })); -} else { - process.exit(0); } diff --git a/test/parallel/test-worker-stdio-flush-inflight.js b/test/parallel/test-worker-stdio-flush-inflight.js index 34b81152811e7b..a51656ca1ec880 100644 --- a/test/parallel/test-worker-stdio-flush-inflight.js +++ b/test/parallel/test-worker-stdio-flush-inflight.js @@ -20,5 +20,4 @@ if (isMainThread) { process.stdout.write('hello'); process.stdout.write(' '); process.stdout.write('world'); - process.exit(0); } diff --git a/test/parallel/test-worker-thread-name.js b/test/parallel/test-worker-thread-name.js index 47e497b07b5164..541761b4e2d1b7 100644 --- a/test/parallel/test-worker-thread-name.js +++ b/test/parallel/test-worker-thread-name.js @@ -8,7 +8,6 @@ const name = 'test-worker-thread-name'; if (workerData?.isWorker) { assert.strictEqual(threadName, name); - process.exit(0); } else { const w = new Worker(__filename, { name, workerData: { isWorker: true } }); assert.strictEqual(w.threadName, name); From 356972a1e45f79805aa25c66922b5cba9c4a61e1 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 27 Feb 2026 14:30:21 +0100 Subject: [PATCH 2/4] fixup! test: remove unnecessary `process.exit` calls from test files --- benchmark/buffers/buffer-transcode.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/benchmark/buffers/buffer-transcode.js b/benchmark/buffers/buffer-transcode.js index abdb06d042d66e..4f985ac408459b 100644 --- a/benchmark/buffers/buffer-transcode.js +++ b/benchmark/buffers/buffer-transcode.js @@ -3,10 +3,12 @@ const common = require('../common.js'); const assert = require('node:assert'); const buffer = require('node:buffer'); +const hasIntl = !!process.config.variables.v8_enable_i18n_support; const encodings = ['latin1', 'ascii', 'ucs2', 'utf8']; -if (!common.hasIntl) { - common.skip('`transcode` is only available on platforms that support i18n`'); +if (!hasIntl) { + console.log('Skipping: `transcode` is only available on platforms that support i18n`'); + return; } const bench = common.createBenchmark(main, { From 5c35204e0503462a4841993cd8b3f84f2bb8850e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 28 Feb 2026 11:46:07 +0100 Subject: [PATCH 3/4] fixup! test: remove unnecessary `process.exit` calls from test files --- test/parallel/test-runner-run-files-undefined.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-runner-run-files-undefined.mjs b/test/parallel/test-runner-run-files-undefined.mjs index d19063ef60512a..9d08b10a4550cd 100644 --- a/test/parallel/test-runner-run-files-undefined.mjs +++ b/test/parallel/test-runner-run-files-undefined.mjs @@ -6,7 +6,8 @@ import { fork } from 'node:child_process'; import assert from 'node:assert'; if (common.hasCrypto) { - common.skip('no crypto'); + console.log('1..0 # Skipped: no crypto'); + process.exit(0); } if (process.env.CHILD === 'true') { From 36f0203652583489380ce894b91bef7ed5ef35b9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 28 Feb 2026 12:00:16 +0100 Subject: [PATCH 4/4] fixup! test: remove unnecessary `process.exit` calls from test files --- test/parallel/test-inspector-port-zero-cluster.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-inspector-port-zero-cluster.js b/test/parallel/test-inspector-port-zero-cluster.js index 79f245ed3e4150..8b17dbee73500b 100644 --- a/test/parallel/test-inspector-port-zero-cluster.js +++ b/test/parallel/test-inspector-port-zero-cluster.js @@ -35,7 +35,7 @@ function serialFork() { if (cluster.isPrimary) { Promise.all([serialFork(), serialFork(), serialFork()]) - .then(common.mustCall((ports) => { + .then((ports) => { ports.splice(0, 0, process.debugPort); // 4 = [primary, worker1, worker2, worker3].length() assert.strictEqual(ports.length, 4); @@ -44,10 +44,8 @@ if (cluster.isPrimary) { assert.strictEqual(ports[0] === 65535 ? 1024 : ports[0] + 1, ports[1]); assert.strictEqual(ports[1] === 65535 ? 1024 : ports[1] + 1, ports[2]); assert.strictEqual(ports[2] === 65535 ? 1024 : ports[2] + 1, ports[3]); - })) - .catch( - (err) => { - console.error(err); - process.exit(1); - }); + }) + .then(common.mustCall()); +} else { + process.disconnect(); }