Skip to content

Commit 63d8296

Browse files
Fishrock123Myles Borins
authored and
Myles Borins
committed
test: stdin is not always a net.Socket
`<`-ing a file into stdin actually results in a `fs.ReadStream`, rather than a `tty.ReadStream`, and as such does not inherit from net.Socket, unlike the other possible stdin options. Refs: #5916 PR-URL: #5935 Reviewed-By: Colin Ihrig <[email protected]>
1 parent f60ce10 commit 63d8296

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/pull/5916
3+
4+
const common = require('../common');
5+
const assert = require('assert');
6+
const spawn = require('child_process').spawn;
7+
const net = require('net');
8+
9+
if (process.argv[2] === 'child') {
10+
assert(process.stdin instanceof net.Socket);
11+
return;
12+
}
13+
14+
const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'ignore' });
15+
// To double-check this test, set stdio to 'pipe' and uncomment the line below.
16+
// proc.stderr.pipe(process.stderr);
17+
proc.on('exit', common.mustCall(function(exitCode) {
18+
process.exitCode = exitCode;
19+
}));

0 commit comments

Comments
 (0)