Skip to content

Commit 1994ac0

Browse files
addaleaxMyles Borins
authored andcommitted
test: add test for piping large input from stdin
Check that piping a large chunk of data from `process.stdin` into `process.stdout` does not lose any data by verifying that the output has the same size as the input. This is a regression test for #5927 and fails for the commits in the range [ace1009..89abe86). PR-URL: #5949 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent c33a23f commit 1994ac0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
// See https://github.com/nodejs/node/issues/5927
3+
4+
constcommon=require('../common');
5+
constassert=require('assert');
6+
constspawn=require('child_process').spawn;
7+
8+
if(process.argv[2]==='child'){
9+
process.stdin.pipe(process.stdout);
10+
return;
11+
}
12+
13+
constchild=spawn(process.execPath,[__filename,'child'],{stdio: 'pipe'});
14+
15+
constexpectedBytes=1024*1024;
16+
letreadBytes=0;
17+
18+
child.stdin.end(Buffer(expectedBytes));
19+
20+
child.stdout.on('data',(chunk)=>readBytes+=chunk.length);
21+
child.stdout.on('end',common.mustCall(()=>{
22+
assert.strictEqual(readBytes,expectedBytes);
23+
}));

0 commit comments

Comments
 (0)