Skip to content

Commit abd3ecf

Browse files
committed
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: #1067 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Nikolai Vavilov <[email protected]>
1 parent 4d0329e commit abd3ecf

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/fixtures/echo-close-check.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var common = require('../common');
22
var assert = require('assert');
33
var net = require('net');
4+
var fs = require('fs');
45

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

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

1314
stdin.on('end', function() {
14-
// If stdin's fd will be closed - createServer may get it
15-
var server = net.createServer(function() {
16-
}).listen(common.PORT, function() {
17-
assert(typeof server._handle.fd !== 'number' || server._handle.fd > 2);
18-
server.close();
19-
});
15+
// If stdin's fd was closed, the next open() call would return 0.
16+
var fd = fs.openSync(process.argv[1], 'r');
17+
assert(fd > 2);
18+
fs.closeSync(fd);
2019
});

0 commit comments

Comments
 (0)