Fix test-module-load-list
and lazy load modules for process.stdout This probably breaks test-module-load-list on windows, but it hopefully is an easy fix to replace "_posix" bindings with "_win32".
This commit is contained in:
parent
0aad61e802
commit
0928f0f290
22
src/node.js
22
src/node.js
@ -219,27 +219,31 @@
|
|||||||
if (stdout) return stdout;
|
if (stdout) return stdout;
|
||||||
|
|
||||||
var binding = process.binding('stdio'),
|
var binding = process.binding('stdio'),
|
||||||
// FIXME Remove conditional when net is supported again on windows.
|
|
||||||
net = (process.platform !== "win32")
|
|
||||||
? NativeModule.require('net')
|
|
||||||
: undefined,
|
|
||||||
fs = NativeModule.require('fs'),
|
|
||||||
tty = NativeModule.require('tty'),
|
|
||||||
fd = binding.stdoutFD;
|
fd = binding.stdoutFD;
|
||||||
|
|
||||||
|
// Note stdout._type is used for test-module-load-list.js
|
||||||
|
|
||||||
if (binding.isatty(fd)) {
|
if (binding.isatty(fd)) {
|
||||||
binding.unref();
|
binding.unref();
|
||||||
|
var tty = NativeModule.require('tty');
|
||||||
stdout = new tty.WriteStream(fd);
|
stdout = new tty.WriteStream(fd);
|
||||||
|
stdout._type = "tty";
|
||||||
} else if (binding.isStdoutBlocking()) {
|
} else if (binding.isStdoutBlocking()) {
|
||||||
|
var fs = NativeModule.require('fs');
|
||||||
stdout = new fs.WriteStream(null, {fd: fd});
|
stdout = new fs.WriteStream(null, {fd: fd});
|
||||||
|
stdout._type = "fs";
|
||||||
} else {
|
} else {
|
||||||
binding.unref();
|
binding.unref();
|
||||||
|
|
||||||
|
var net = NativeModule.require('net');
|
||||||
stdout = new net.Stream(fd);
|
stdout = new net.Stream(fd);
|
||||||
|
|
||||||
// FIXME Should probably have an option in net.Stream to create a
|
// FIXME Should probably have an option in net.Stream to create a
|
||||||
// stream from an existing fd which is writable only. But for now
|
// stream from an existing fd which is writable only. But for now
|
||||||
// we'll just add this hack and set the `readable` member to false.
|
// we'll just add this hack and set the `readable` member to false.
|
||||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||||
stdout.readable = false;
|
stdout.readable = false;
|
||||||
|
stdout._type = "pipe";
|
||||||
}
|
}
|
||||||
|
|
||||||
return stdout;
|
return stdout;
|
||||||
@ -255,16 +259,16 @@
|
|||||||
if (stdin) return stdin;
|
if (stdin) return stdin;
|
||||||
|
|
||||||
var binding = process.binding('stdio'),
|
var binding = process.binding('stdio'),
|
||||||
net = NativeModule.require('net'),
|
|
||||||
fs = NativeModule.require('fs'),
|
|
||||||
tty = NativeModule.require('tty'),
|
|
||||||
fd = binding.openStdin();
|
fd = binding.openStdin();
|
||||||
|
|
||||||
if (binding.isatty(fd)) {
|
if (binding.isatty(fd)) {
|
||||||
|
var tty = NativeModule.require('tty');
|
||||||
stdin = new tty.ReadStream(fd);
|
stdin = new tty.ReadStream(fd);
|
||||||
} else if (binding.isStdinBlocking()) {
|
} else if (binding.isStdinBlocking()) {
|
||||||
|
var fs = NativeModule.require('fs');
|
||||||
stdin = new fs.ReadStream(null, {fd: fd});
|
stdin = new fs.ReadStream(null, {fd: fd});
|
||||||
} else {
|
} else {
|
||||||
|
var net = NativeModule.require('net');
|
||||||
stdin = new net.Stream(fd);
|
stdin = new net.Stream(fd);
|
||||||
stdin.readable = true;
|
stdin.readable = true;
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,8 @@ function assertEqual(x, y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkExpected() {
|
function checkExpected() {
|
||||||
assertEqual(expected.length, process.moduleLoadList.length);
|
var toCompare = Math.max(expected.length, process.moduleLoadList.length);
|
||||||
|
for (var i = 0; i < toCompare; i++) {
|
||||||
for (var i = 0; i < expected.length; i++) {
|
|
||||||
assertEqual(expected[i], process.moduleLoadList[i]);
|
assertEqual(expected[i], process.moduleLoadList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,8 +55,8 @@ checkExpected();
|
|||||||
|
|
||||||
|
|
||||||
// Now do the test again after we console.log something.
|
// Now do the test again after we console.log something.
|
||||||
console.log("load console.log");
|
console.log("load console.log. process.stdout._type is " +
|
||||||
console.error("load console.error");
|
process.stdout._type);
|
||||||
|
|
||||||
if (!process.features.uv) {
|
if (!process.features.uv) {
|
||||||
// legacy
|
// legacy
|
||||||
@ -75,31 +74,55 @@ if (!process.features.uv) {
|
|||||||
'NativeModule readline'
|
'NativeModule readline'
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
if (process.platform == 'win32') {
|
switch (process.stdout._type) {
|
||||||
// win32
|
case 'fs':
|
||||||
|
expected = expected.concat([
|
||||||
|
'NativeModule console',
|
||||||
|
'NativeModule readline',
|
||||||
|
'NativeModule tty',
|
||||||
|
'NativeModule tty_posix',
|
||||||
|
'NativeModule net_uv',
|
||||||
|
'NativeModule timers_uv',
|
||||||
|
'Binding timer_wrap',
|
||||||
|
'NativeModule _linklist',
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'tty':
|
||||||
expected = expected.concat([
|
expected = expected.concat([
|
||||||
'NativeModule console',
|
'NativeModule console',
|
||||||
'NativeModule tty',
|
'NativeModule tty',
|
||||||
'NativeModule tty_win32',
|
'NativeModule tty_posix',
|
||||||
|
'NativeModule net_uv',
|
||||||
|
'NativeModule timers_uv',
|
||||||
|
'Binding timer_wrap',
|
||||||
|
'NativeModule _linklist',
|
||||||
|
'Binding pipe_wrap',
|
||||||
'NativeModule readline'
|
'NativeModule readline'
|
||||||
]);
|
]);
|
||||||
} else {
|
break;
|
||||||
// unix libuv backend.
|
|
||||||
|
case 'pipe':
|
||||||
expected = expected.concat([
|
expected = expected.concat([
|
||||||
'NativeModule console',
|
'NativeModule console',
|
||||||
'NativeModule net_uv',
|
'NativeModule net_uv',
|
||||||
'NativeModule timers_uv',
|
'NativeModule timers_uv',
|
||||||
'Binding timer_wrap',
|
'Binding timer_wrap',
|
||||||
'NativeModule _linklist',
|
'NativeModule _linklist',
|
||||||
|
'Binding pipe_wrap',
|
||||||
|
'NativeModule readline',
|
||||||
'NativeModule tty',
|
'NativeModule tty',
|
||||||
'NativeModule tty_posix',
|
'NativeModule tty_posix',
|
||||||
'Binding pipe_wrap',
|
|
||||||
'NativeModule readline'
|
|
||||||
]);
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert.ok(0, "prcoess.stdout._type is bad");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(process.moduleLoadList)
|
console.error("process.moduleLoadList", process.moduleLoadList)
|
||||||
|
console.error("expected", expected)
|
||||||
|
|
||||||
checkExpected();
|
checkExpected();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user