From 19a8d22c77f55858d8dfb1fa593837112fb4aad2 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 10 Oct 2019 21:30:12 +0200 Subject: [PATCH] test: do not force the process to exit Using `process.exit()` in these tests is unnecessary and may mask other problems. Refs: https://github.com/nodejs/node/pull/29873#pullrequestreview-298851847 PR-URL: https://github.com/nodejs/node/pull/29923 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Jeremiah Senkpiel Reviewed-By: David Carlier Reviewed-By: Anto Aravinth Reviewed-By: Yongsheng Zhang --- test/parallel/test-cluster-net-send.js | 1 - test/parallel/test-http-date-header.js | 1 - test/parallel/test-http-expect-continue.js | 1 - test/parallel/test-http-localaddress.js | 1 - test/parallel/test-http-set-trailers.js | 3 --- test/parallel/test-https-localaddress.js | 1 - test/parallel/test-https-timeout.js | 7 ++++++- test/parallel/test-timers-non-integer-delay.js | 1 - 8 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-cluster-net-send.js b/test/parallel/test-cluster-net-send.js index 14ce58474f128e..9e0ad6b3be5594 100644 --- a/test/parallel/test-cluster-net-send.js +++ b/test/parallel/test-cluster-net-send.js @@ -72,7 +72,6 @@ if (process.argv[2] !== 'child') { }); process.on('disconnect', function() { - process.exit(); server.close(); }); } diff --git a/test/parallel/test-http-date-header.js b/test/parallel/test-http-date-header.js index b389e33664738c..169af2bf2a58c4 100644 --- a/test/parallel/test-http-date-header.js +++ b/test/parallel/test-http-date-header.js @@ -48,7 +48,6 @@ server.addListener('listening', () => { 'Response headers didn\'t contain a Date.'); res.addListener('end', () => { server.close(); - process.exit(); }); res.resume(); }); diff --git a/test/parallel/test-http-expect-continue.js b/test/parallel/test-http-expect-continue.js index 10bcb9d568ff35..9d24a9278d82ea 100644 --- a/test/parallel/test-http-expect-continue.js +++ b/test/parallel/test-http-expect-continue.js @@ -76,7 +76,6 @@ server.on('listening', common.mustCall(() => { assert.strictEqual(body, test_res_body); assert.ok('abcd' in res.headers, 'Response headers missing.'); server.close(); - process.exit(); })); })); })); diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index 47af784e9a226e..e237c3bff1ac84 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -49,7 +49,6 @@ server.listen(0, '127.0.0.1', () => { const req = http.request(options, function(res) { res.on('end', () => { server.close(); - process.exit(); }); res.resume(); }); diff --git a/test/parallel/test-http-set-trailers.js b/test/parallel/test-http-set-trailers.js index 9068ef8f769937..921c456bdaddfd 100644 --- a/test/parallel/test-http-set-trailers.js +++ b/test/parallel/test-http-set-trailers.js @@ -61,7 +61,6 @@ server.on('listening', function() { outstanding_reqs--; if (outstanding_reqs === 0) { server.close(); - process.exit(); } }); }); @@ -91,7 +90,6 @@ server.on('listening', function() { ); if (outstanding_reqs === 0) { server.close(); - process.exit(); } } }); @@ -110,7 +108,6 @@ server.on('listening', function() { outstanding_reqs--; if (outstanding_reqs === 0) { server.close(); - process.exit(); } }); res.resume(); diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index 6c6cac37ccca3b..0ac8414b2d4b35 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -61,7 +61,6 @@ server.listen(0, '127.0.0.1', function() { const req = https.request(options, function(res) { res.on('end', function() { server.close(); - process.exit(); }); res.resume(); }); diff --git a/test/parallel/test-https-timeout.js b/test/parallel/test-https-timeout.js index 9ba621e436859e..6955ef0af190aa 100644 --- a/test/parallel/test-https-timeout.js +++ b/test/parallel/test-https-timeout.js @@ -51,10 +51,15 @@ const server = https.createServer(options, function() { console.log('got response'); }); + req.on('error', common.expectsError({ + message: 'socket hang up', + code: 'ECONNRESET', + type: Error + })); + req.on('timeout', common.mustCall(function() { console.log('timeout occurred outside'); req.destroy(); server.close(); - process.exit(0); })); })); diff --git a/test/parallel/test-timers-non-integer-delay.js b/test/parallel/test-timers-non-integer-delay.js index 15b405e9a48dd4..eabfc560264cde 100644 --- a/test/parallel/test-timers-non-integer-delay.js +++ b/test/parallel/test-timers-non-integer-delay.js @@ -45,7 +45,6 @@ let N = 50; const interval = setInterval(common.mustCall(() => { if (--N === 0) { clearInterval(interval); - process.exit(0); } }, N), TIMEOUT_DELAY);