Skip to content

Commit

Permalink
test: modernize test-child-process-flush-stdio
Browse files Browse the repository at this point in the history
PR-URL: #23504
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Viacheslav Liakhov authored and rvagg committed Nov 28, 2018
1 parent df22a06 commit 2955c8b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/parallel/test-child-process-flush-stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ const opts = { shell: common.isWindows };

const p = cp.spawn('echo', [], opts);

p.on('close', common.mustCall(function(code, signal) {
p.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
spawnWithReadable();
}));

p.stdout.read();

function spawnWithReadable() {
const spawnWithReadable = () => {
const buffer = [];
const p = cp.spawn('echo', ['123'], opts);
p.on('close', common.mustCall(function(code, signal) {
p.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
assert.strictEqual(Buffer.concat(buffer).toString().trim(), '123');
}));
p.stdout.on('readable', function() {
p.stdout.on('readable', () => {
let buf;
while (buf = this.read())
while (buf = p.stdout.read())
buffer.push(buf);
});
}
};

0 comments on commit 2955c8b

Please sign in to comment.