diff --git a/benchmark/buffers/buffer-transcode.js b/benchmark/buffers/buffer-transcode.js index cbb3b2e9b16374..4f985ac408459b 100644 --- a/benchmark/buffers/buffer-transcode.js +++ b/benchmark/buffers/buffer-transcode.js @@ -8,7 +8,7 @@ const encodings = ['latin1', 'ascii', 'ucs2', 'utf8']; if (!hasIntl) { console.log('Skipping: `transcode` is only available on platforms that support i18n`'); - process.exit(0); + return; } 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..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,12 +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.exit(0); + process.disconnect(); } 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-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);