Skip to content

Commit

Permalink
test: fix flaky test-child-process-pass-fd
Browse files Browse the repository at this point in the history
Listen on random ports instead of using `common.PORT`.

Fixes: #8209
PR-URL: #8212
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
  • Loading branch information
santigimeno authored and evanlucas committed Aug 24, 2016
1 parent e371545 commit bb6d6a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/sequential/test-child-process-pass-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const N = 80;

if (process.argv[2] !== 'child') {
for (let i = 0; i < N; ++i) {
const worker = fork(__filename, ['child', common.PORT + i]);
const worker = fork(__filename, ['child']);
worker.once('message', common.mustCall((msg, handle) => {
assert.strictEqual(msg, 'handle');
assert.ok(handle);
Expand All @@ -33,7 +33,6 @@ if (process.argv[2] !== 'child') {
}
} else {
let socket;
const port = process.argv[3];
let cbcalls = 0;
function socketConnected() {
if (++cbcalls === 2)
Expand All @@ -47,7 +46,8 @@ if (process.argv[2] !== 'child') {
});
socketConnected();
});
server.listen(port, common.localhostIPv4, () => {
server.listen(0, common.localhostIPv4, () => {
const port = server.address().port;
socket = net.connect(port, common.localhostIPv4, socketConnected);
});
}

0 comments on commit bb6d6a6

Please sign in to comment.