diff options
author | Rich Trott <rtrott@gmail.com> | 2017-05-14 12:42:37 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-05-19 21:42:52 -0700 |
commit | 525497596a51ef2e6653b930ca525046d27c9fd5 (patch) | |
tree | 789736bb5dc25ffb59c6c117e112602e3b314f94 /test/sequential/test-net-GH-5504.js | |
parent | 658741b9d9255c5e18fafa76f3a70876153c8d59 (diff) | |
download | android-node-v8-525497596a51ef2e6653b930ca525046d27c9fd5.tar.gz android-node-v8-525497596a51ef2e6653b930ca525046d27c9fd5.tar.bz2 android-node-v8-525497596a51ef2e6653b930ca525046d27c9fd5.zip |
test: refactor test-net-GH-5504
* Improve comments describing test.
* Remove unnecessary `common.noop`
* Remove confusing scoping of `c` identifier
PR-URL: https://github.com/nodejs/node/pull/13025
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/sequential/test-net-GH-5504.js')
-rw-r--r-- | test/sequential/test-net-GH-5504.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index 0c4d9bc694..d744525710 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -22,11 +22,13 @@ 'use strict'; const common = require('../common'); -// this test only fails with CentOS 6.3 using kernel version 2.6.32 -// On other linuxes and darwin, the `read` call gets an ECONNRESET in +// Ref: https://github.com/nodejs/node-v0.x-archive/issues/5504 +// +// This test only fails with CentOS 6.3 using kernel version 2.6.32. +// On other Linuxes and macOS, the `read` call gets an ECONNRESET in // that case. On sunos, the `write` call fails with EPIPE. // -// However, old CentOS will occasionally send an EOF instead of a +// However, old CentOS will occasionally send an EOF instead of an // ECONNRESET or EPIPE when the client has been destroyed abruptly. // // Make sure we don't keep trying to write or read more in that case. @@ -74,25 +76,24 @@ function parent() { NODE_DEBUG: 'net' }) }); - let c; wrap(s.stderr, process.stderr, 'SERVER 2>'); wrap(s.stdout, process.stdout, 'SERVER 1>'); - s.on('exit', common.mustCall(common.noop)); + s.on('exit', common.mustCall()); s.stdout.once('data', common.mustCall(function() { - c = spawn(node, [__filename, 'client']); + const c = spawn(node, [__filename, 'client']); wrap(c.stderr, process.stderr, 'CLIENT 2>'); wrap(c.stdout, process.stdout, 'CLIENT 1>'); - c.on('exit', common.mustCall(common.noop)); + c.on('exit', common.mustCall()); })); function wrap(inp, out, w) { inp.setEncoding('utf8'); - inp.on('data', function(c) { - c = c.trim(); - if (!c) return; - out.write(`${w}${c.split('\n').join(`\n${w}`)}\n`); + inp.on('data', function(chunk) { + chunk = chunk.trim(); + if (!chunk) return; + out.write(`${w}${chunk.split('\n').join(`\n${w}`)}\n`); }); } } |