Skip to content

Commit 1ba472d

Browse files
joyeecheungjungx098
authored andcommitted
test: fail when child dies in fork-net
Previously when the child dies with errors in this test, the parent will just hang and timeout, the errors in the child would be swallowed. This makes it fail so at least there is more information about why this test fails. Also removes the unnecessary child.kill() call. PR-URL: nodejs#11684 Ref: nodejs#11667 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 12dc1bf commit 1ba472d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/parallel/test-child-process-fork-net.js

Lines changed: 5 additions & 5 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 fork = require('child_process').fork;
2626
const net = require('net');
@@ -81,9 +81,10 @@ if (process.argv[2] === 'child') {
8181

8282
const child = fork(process.argv[1], ['child']);
8383

84-
child.on('exit', function() {
85-
console.log('CHILD: died');
86-
});
84+
child.on('exit', common.mustCall(function(code, signal) {
85+
const message = `CHILD: died with ${code}, ${signal}`;
86+
assert.strictEqual(code, 0, message);
87+
}));
8788

8889
// send net.Server to child and test by connecting
8990
const testServer = function(callback) {
@@ -192,7 +193,6 @@ if (process.argv[2] === 'child') {
192193

193194
testSocket(function() {
194195
socketSuccess = true;
195-
child.kill();
196196
});
197197
});
198198

0 commit comments

Comments
 (0)