0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/fixtures/echo-close-check.js
Bert Belder abd3ecfbd1 win,test: fix test-stdin-from-file
The test-stdin-from-from-file test runs a subprocess that verifies stdin
can be piped from a file.

The subprocess additionally attempts to verify that the file descriptor
for stdin never gets closed. It used to do this by creating a TCP server
and asserting that the associated file descriptor is greater than two.
However this strategy doesn't work on windows, because servers don't
have an associated file descriptor. With this patch an ordinary file is
opened instead of creating a server.

PR: https://github.com/iojs/io.js/pull/1067
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
2015-03-05 15:30:52 +01:00

20 lines
459 B
JavaScript

var common = require('../common');
var assert = require('assert');
var net = require('net');
var fs = require('fs');
process.stdout.write('hello world\r\n');
var stdin = process.openStdin();
stdin.on('data', function(data) {
process.stdout.write(data.toString());
});
stdin.on('end', function() {
// If stdin's fd was closed, the next open() call would return 0.
var fd = fs.openSync(process.argv[1], 'r');
assert(fd > 2);
fs.closeSync(fd);
});