Skip to content

Commit

Permalink
win,test: fix test-stdin-from-file
Browse files Browse the repository at this point in the history
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: #1067
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
  • Loading branch information
piscisaureus committed Mar 5, 2015
1 parent 4d0329e commit abd3ecf
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/fixtures/echo-close-check.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var common = require('../common');
var assert = require('assert');
var net = require('net');
var fs = require('fs');

process.stdout.write('hello world\r\n');

Expand All @@ -11,10 +12,8 @@ stdin.on('data', function(data) {
});

stdin.on('end', function() {
// If stdin's fd will be closed - createServer may get it
var server = net.createServer(function() {
}).listen(common.PORT, function() {
assert(typeof server._handle.fd !== 'number' || server._handle.fd > 2);
server.close();
});
// 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);
});

3 comments on commit abd3ecf

@rvagg
Copy link
Member

@rvagg rvagg commented on abd3ecf Mar 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this commit has PR: rather than PR-URL:

@piscisaureus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvagg doh, I always use PR:. I'll use PR-URL next time.

@rvagg
Copy link
Member

@rvagg rvagg commented on abd3ecf Mar 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I know this isn't a one-off I've updated changelog-maker: nodejs/changelog-maker@04e1959

Please sign in to comment.