Skip to content

Commit

Permalink
test: fail when child dies in fork-net
Browse files Browse the repository at this point in the history
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/node#11684
Ref: nodejs/node#11667
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and andrew749 committed Jul 19, 2017
1 parent cb596f1 commit d070f81
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/parallel/test-child-process-fork-net.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');
Expand Down Expand Up @@ -60,9 +60,10 @@ if (process.argv[2] === 'child') {

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

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

// send net.Server to child and test by connecting
const testServer = function(callback) {
Expand Down Expand Up @@ -171,7 +172,6 @@ if (process.argv[2] === 'child') {

testSocket(function() {
socketSuccess = true;
child.kill();
});
});

Expand Down

0 comments on commit d070f81

Please sign in to comment.