Browse Source

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: https://github.com/nodejs/node/pull/11684
Ref: https://github.com/nodejs/node/pull/11667
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Joyee Cheung 8 years ago
committed by Myles Borins
parent
commit
4d916da0d7
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 10
      test/parallel/test-child-process-fork-net.js

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

@ -1,5 +1,5 @@
'use strict'; 'use strict';
require('../common'); const common = require('../common');
const assert = require('assert'); const assert = require('assert');
const fork = require('child_process').fork; const fork = require('child_process').fork;
const net = require('net'); const net = require('net');
@ -60,9 +60,10 @@ if (process.argv[2] === 'child') {
const child = fork(process.argv[1], ['child']); const child = fork(process.argv[1], ['child']);
child.on('exit', function() { child.on('exit', common.mustCall(function(code, signal) {
console.log('CHILD: died'); const message = `CHILD: died with ${code}, ${signal}`;
}); assert.strictEqual(code, 0, message);
}));
// send net.Server to child and test by connecting // send net.Server to child and test by connecting
const testServer = function(callback) { const testServer = function(callback) {
@ -171,7 +172,6 @@ if (process.argv[2] === 'child') {
testSocket(function() { testSocket(function() {
socketSuccess = true; socketSuccess = true;
child.kill();
}); });
}); });

Loading…
Cancel
Save