Skip to content

Commit aa0c7b0

Browse files
aduh95richardlau
authored andcommitted
test: remove unnecessary process.exit calls from test files
PR-URL: #62020 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent ad96a65 commit aa0c7b0

17 files changed

+22
-43
lines changed

benchmark/buffers/buffer-transcode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const encodings = ['latin1', 'ascii', 'ucs2', 'utf8'];
88

99
if (!hasIntl) {
1010
console.log('Skipping: `transcode` is only available on platforms that support i18n`');
11-
process.exit(0);
11+
return;
1212
}
1313

1414
const bench = common.createBenchmark(main, {

test/parallel/test-child-process-fork-advanced-header-serialization.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ if (process.argv[2] === 'child-buffer') {
1313
v & 0xFF,
1414
]);
1515
const fd = process.channel?.fd;
16-
if (fd === undefined) {
17-
// skip test
18-
process.exit(0);
16+
if (fd !== undefined) {
17+
fs.writeSync(fd, payload);
1918
}
20-
fs.writeSync(fd, payload);
2119
return;
2220
}
2321

test/parallel/test-child-process-internal.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ if (process.argv[2] === 'child') {
3434

3535
// Send internal message
3636
process.send(internal);
37-
38-
process.exit(0);
39-
4037
} else {
4138

4239
const fork = require('child_process').fork;

test/parallel/test-child-process-silent.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
require('../common');
23+
const common = require('../common');
2424
const assert = require('assert');
2525
const childProcess = require('child_process');
2626

@@ -44,9 +44,7 @@ if (process.argv[2] === 'pipe') {
4444
// Allow child process to self terminate
4545
child.disconnect();
4646

47-
child.on('exit', function() {
48-
process.exit(0);
49-
});
47+
child.on('exit', common.mustCall());
5048

5149
} else {
5250
// Testcase | start primary && child IPC test

test/parallel/test-child-process-spawnsync-input.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ if (process.argv.includes('spawnchild')) {
6565
checkSpawnSyncRet(ret);
6666
break;
6767
}
68-
process.exit(0);
6968
return;
7069
}
7170

test/parallel/test-child-process-stdout-flush-exit.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ if (process.argv[2] === 'child') {
3636
console.log('filler');
3737
}
3838
console.log('goodbye');
39-
process.exit(0);
4039
} else {
4140
// parent process
4241
const spawn = require('child_process').spawn;

test/parallel/test-cli-eval.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const fixtures = require('../common/fixtures');
3535

3636
if (process.argv.length > 2) {
3737
console.log(process.argv.slice(2).join(' '));
38-
process.exit(0);
38+
return;
3939
}
4040

4141
// Assert that nothing is written to stdout.

test/parallel/test-inspector-port-zero-cluster.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function serialFork() {
3535

3636
if (cluster.isPrimary) {
3737
Promise.all([serialFork(), serialFork(), serialFork()])
38-
.then(common.mustCall((ports) => {
38+
.then((ports) => {
3939
ports.splice(0, 0, process.debugPort);
4040
// 4 = [primary, worker1, worker2, worker3].length()
4141
assert.strictEqual(ports.length, 4);
@@ -44,12 +44,8 @@ if (cluster.isPrimary) {
4444
assert.strictEqual(ports[0] === 65535 ? 1024 : ports[0] + 1, ports[1]);
4545
assert.strictEqual(ports[1] === 65535 ? 1024 : ports[1] + 1, ports[2]);
4646
assert.strictEqual(ports[2] === 65535 ? 1024 : ports[2] + 1, ports[3]);
47-
}))
48-
.catch(
49-
(err) => {
50-
console.error(err);
51-
process.exit(1);
52-
});
47+
})
48+
.then(common.mustCall());
5349
} else {
54-
process.exit(0);
50+
process.disconnect();
5551
}

test/parallel/test-net-listen-twice.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (cluster.isPrimary) {
1919
server.listen();
2020
} catch (e) {
2121
console.error(e);
22-
process.exit(0);
22+
return;
2323
}
2424
let i = 0;
2525
process.on('internalMessage', (msg) => {

test/parallel/test-permission-allow-child-process-cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (process.argv[2] === 'child') {
2424
code: 'ERR_ACCESS_DENIED',
2525
permission: 'FileSystemWrite',
2626
}));
27-
process.exit(0);
27+
return;
2828
}
2929

3030
// Guarantee the initial state

0 commit comments

Comments
 (0)