blob: ac890cf75844db60e131969d69807f68d64bfc98 [file] [log] [blame]
Roman Reissf29762f2015-05-19 11:00:061/* eslint-disable max-len, strict */
Ryan Dahla0159b42010-12-04 23:20:342var common = require('../common');
3var assert = require('assert');
Ryan Dahla6942b32010-06-08 00:39:244
Ryan Dahl02cc39f2010-12-04 21:40:395common.globalCheck = false;
6
Oleg Efimov0ce9cba2010-12-04 22:45:527var net = require('net'),
8 repl = require('repl'),
9 message = 'Read, Eval, Print Loop',
Oleg Efimov0ce9cba2010-12-04 22:45:5210 prompt_unix = 'node via Unix socket> ',
11 prompt_tcp = 'node via TCP socket> ',
12 prompt_multiline = '... ',
isaacs28e851c2012-06-05 19:02:3713 prompt_npm = 'npm should be run outside of the ' +
14 'node repl, in your normal shell.\n' +
15 '(Press Control-D to exit.)\n',
16 expect_npm = prompt_npm + prompt_unix,
Fedor Indutny1a52d6a2014-07-31 08:12:1817 server_tcp, server_unix, client_tcp, client_unix, timer;
Ryan Dahla6942b32010-06-08 00:39:2418
Ryan Dahl03a119e2011-08-09 23:06:3219
Ryan Dahl49627022010-09-19 18:20:2520// absolute path to test/fixtures/a.js
Oleg Efimov0ce9cba2010-12-04 22:45:5221var moduleFilename = require('path').join(common.fixturesDir, 'a');
Ryan Dahl49627022010-09-19 18:20:2522
isaacs4631c502013-08-28 01:53:3923console.error('repl test');
Matt Ranneyb7441042010-04-11 23:13:3224
25// function for REPL to run
Oleg Efimov0ce9cba2010-12-04 22:45:5226invoke_me = function(arg) {
27 return 'invoked ' + arg;
Matt Ranneyb7441042010-04-11 23:13:3228};
29
30function send_expect(list) {
31 if (list.length > 0) {
32 var cur = list.shift();
33
isaacs4631c502013-08-28 01:53:3934 console.error('sending ' + JSON.stringify(cur.send));
Ryan Dahla6942b32010-06-08 00:39:2435
Matt Ranneyb7441042010-04-11 23:13:3236 cur.client.expect = cur.expect;
37 cur.client.list = list;
38 if (cur.send.length > 0) {
Nathan Rajlichaab7cb72012-04-06 19:20:0139 cur.client.write(cur.send + '\n');
Matt Ranneyb7441042010-04-11 23:13:3240 }
41 }
42}
43
Marco Rogers118b88e2010-11-20 23:44:5844function clean_up() {
45 client_tcp.end();
46 client_unix.end();
47 clearTimeout(timer);
48}
49
50function error_test() {
Ryan Dahl08d81162010-12-01 21:43:0551 // The other stuff is done so reuse unix socket
Oleg Efimov0ce9cba2010-12-04 22:45:5252 var read_buffer = '';
Ryan Dahl08d81162010-12-01 21:43:0553 client_unix.removeAllListeners('data');
Marco Rogers118b88e2010-11-20 23:44:5854
Ben Noordhuis018e1102011-10-14 23:08:3655 client_unix.on('data', function(data) {
Ryan Dahl08d81162010-12-01 21:43:0556 read_buffer += data.toString('ascii', 0, data.length);
isaacs4631c502013-08-28 01:53:3957 console.error('Unix data: ' + JSON.stringify(read_buffer) + ', expecting ' +
Oleg Efimov0ce9cba2010-12-04 22:45:5258 (client_unix.expect.exec ?
59 client_unix.expect :
60 JSON.stringify(client_unix.expect)));
Marco Rogers118b88e2010-11-20 23:44:5861
Ryan Dahl08d81162010-12-01 21:43:0562 if (read_buffer.indexOf(prompt_unix) !== -1) {
isaacs28e851c2012-06-05 19:02:3763 // if it's an exact match, then don't do the regexp
64 if (read_buffer !== client_unix.expect) {
Yazhong Liu613654e2014-07-01 13:35:3565 var expect = client_unix.expect;
66 if (expect === prompt_multiline)
67 expect = /[\.]{3} /;
68 assert.ok(read_buffer.match(expect));
isaacs4631c502013-08-28 01:53:3969 console.error('match');
isaacs28e851c2012-06-05 19:02:3770 }
Oleg Efimov0ce9cba2010-12-04 22:45:5271 read_buffer = '';
Ryan Dahl08d81162010-12-01 21:43:0572 if (client_unix.list && client_unix.list.length > 0) {
73 send_expect(client_unix.list);
74 } else {
isaacs4631c502013-08-28 01:53:3975 console.error('End of Error test, running TCP test.');
Ryan Dahl08d81162010-12-01 21:43:0576 tcp_test();
77 }
78
seebees3421f432011-11-12 01:44:3979 } else if (read_buffer.indexOf(prompt_multiline) !== -1) {
Ryan Dahl08d81162010-12-01 21:43:0580 // Check that you meant to send a multiline test
81 assert.strictEqual(prompt_multiline, client_unix.expect);
Oleg Efimov0ce9cba2010-12-04 22:45:5282 read_buffer = '';
Ryan Dahl08d81162010-12-01 21:43:0583 if (client_unix.list && client_unix.list.length > 0) {
84 send_expect(client_unix.list);
85 } else {
isaacs4631c502013-08-28 01:53:3986 console.error('End of Error test, running TCP test.\n');
Ryan Dahl08d81162010-12-01 21:43:0587 tcp_test();
88 }
89
90 } else {
isaacs4631c502013-08-28 01:53:3991 console.error('didn\'t see prompt yet, buffering.');
Ryan Dahl08d81162010-12-01 21:43:0592 }
93 });
94
95 send_expect([
96 // Uncaught error throws and prints out
Oleg Efimov0ce9cba2010-12-04 22:45:5297 { client: client_unix, send: 'throw new Error(\'test error\');',
98 expect: /^Error: test error/ },
Ryan Dahl08d81162010-12-01 21:43:0599 // Common syntax error is treated as multiline command
Oleg Efimov0ce9cba2010-12-04 22:45:52100 { client: client_unix, send: 'function test_func() {',
101 expect: prompt_multiline },
Ryan Dahl08d81162010-12-01 21:43:05102 // You can recover with the .break command
Oleg Efimov0ce9cba2010-12-04 22:45:52103 { client: client_unix, send: '.break',
104 expect: prompt_unix },
isaacs4631c502013-08-28 01:53:39105 // But passing the same string to eval() should throw
106 { client: client_unix, send: 'eval("function test_func() {")',
107 expect: /^SyntaxError: Unexpected end of input/ },
Xiaowei Lib7365c12015-01-19 05:42:05108 // Can handle multiline template literals
109 { client: client_unix, send: '`io.js',
110 expect: prompt_multiline },
111 // Special REPL commands still available
112 { client: client_unix, send: '.break',
113 expect: prompt_unix },
114 // Template expressions can cross lines
115 { client: client_unix, send: '`io.js ${"1.0"',
116 expect: prompt_multiline },
117 { client: client_unix, send: '+ ".2"}`',
118 expect: `'io.js 1.0.2'\n${prompt_unix}` },
Ben Noordhuisb6e98972012-11-10 17:21:13119 // Floating point numbers are not interpreted as REPL commands.
120 { client: client_unix, send: '.1234',
121 expect: '0.1234' },
Nirk Niggler0459a232013-01-03 14:27:55122 // Floating point expressions are not interpreted as REPL commands
Ben Noordhuis8a65df92013-07-10 07:48:55123 { client: client_unix, send: '.1+.1',
Nirk Niggler0459a232013-01-03 14:27:55124 expect: '0.2' },
Ryan Dahl08d81162010-12-01 21:43:05125 // Can parse valid JSON
Oleg Efimov0ce9cba2010-12-04 22:45:52126 { client: client_unix, send: 'JSON.parse(\'{"valid": "json"}\');',
127 expect: '{ valid: \'json\' }'},
128 // invalid input to JSON.parse error is special case of syntax error,
129 // should throw
130 { client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',
koichik8faf9412011-07-04 19:10:14131 expect: /^SyntaxError: Unexpected token i/ },
Nathan Rajlich3b7312d2012-10-01 18:36:06132 // end of input to JSON.parse error is special case of syntax error,
133 // should throw
Brian White774b28f2013-05-26 16:26:39134 { client: client_unix, send: 'JSON.parse(\'066\');',
135 expect: /^SyntaxError: Unexpected number/ },
136 // should throw
Nathan Rajlich3b7312d2012-10-01 18:36:06137 { client: client_unix, send: 'JSON.parse(\'{\');',
138 expect: /^SyntaxError: Unexpected end of input/ },
Nathan Rajlich4a267072012-09-22 01:46:16139 // invalid RegExps are a special case of syntax error,
140 // should throw
141 { client: client_unix, send: '/(/;',
142 expect: /^SyntaxError: Invalid regular expression\:/ },
Nathan Rajlichf1722a22012-10-01 05:43:35143 // invalid RegExp modifiers are a special case of syntax error,
144 // should throw (GH-4012)
145 { client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
146 expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ },
Nathan Rajlich085f9d62013-03-30 20:10:30147 // strict mode syntax errors should be caught (GH-5178)
148 { client: client_unix, send: '(function() { "use strict"; return 0755; })()',
149 expect: /^SyntaxError: Octal literals are not allowed in strict mode/ },
Nathan Rajlich085f9d62013-03-30 20:10:30150 { client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()',
151 expect: /^SyntaxError: Strict mode function may not have duplicate parameter names/ },
152 { client: client_unix, send: '(function() { "use strict"; with (this) {} })()',
153 expect: /^SyntaxError: Strict mode code may not include a with statement/ },
154 { client: client_unix, send: '(function() { "use strict"; var x; delete x; })()',
155 expect: /^SyntaxError: Delete of an unqualified identifier in strict mode/ },
156 { client: client_unix, send: '(function() { "use strict"; eval = 17; })()',
Fedor Indutnyce04c722014-03-13 16:38:14157 expect: /^SyntaxError: Unexpected eval or arguments in strict mode/ },
Ben Noordhuis6e9d1c82015-01-07 18:16:21158 { client: client_unix, send: '(function() { "use strict"; if (true) function f() { } })()',
Nathan Rajlich085f9d62013-03-30 20:10:30159 expect: /^SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function/ },
Ryan Dahlfeb77ea2011-01-03 02:08:08160 // Named functions can be used:
161 { client: client_unix, send: 'function blah() { return 1; }',
162 expect: prompt_unix },
163 { client: client_unix, send: 'blah()',
Colton Baker87286cc2011-10-04 22:08:18164 expect: '1\n' + prompt_unix },
Fedor Indutnyae5e2332012-02-17 18:18:11165 // Functions should not evaluate twice (#2773)
166 { client: client_unix, send: 'var I = [1,2,3,function() {}]; I.pop()',
167 expect: '[Function]' },
Ryan Dahlfeb77ea2011-01-03 02:08:08168 // Multiline object
169 { client: client_unix, send: '{ a: ',
170 expect: prompt_multiline },
171 { client: client_unix, send: '1 }',
Colton Baker87286cc2011-10-04 22:08:18172 expect: '{ a: 1 }' },
Ryan Dahlfeb77ea2011-01-03 02:08:08173 // Multiline anonymous function with comment
Roman Reissf29762f2015-05-19 11:00:06174 { client: client_unix, send: '(function() {',
Ryan Dahlfeb77ea2011-01-03 02:08:08175 expect: prompt_multiline },
176 { client: client_unix, send: '// blah',
177 expect: prompt_multiline },
178 { client: client_unix, send: 'return 1;',
179 expect: prompt_multiline },
180 { client: client_unix, send: '})()',
isaacs28e851c2012-06-05 19:02:37181 expect: '1' },
182 // npm prompt error message
183 { client: client_unix, send: 'npm install foobar',
Maciej Małecki6a11f3e2012-07-03 02:13:24184 expect: expect_npm },
Roman Reissf29762f2015-05-19 11:00:06185 { client: client_unix, send: '(function() {\n\nreturn 1;\n})()',
Nathan Rajlich9126dd22012-07-04 18:51:24186 expect: '1' },
187 { client: client_unix, send: '{\n\na: 1\n}',
Felix Böhm9bce5e82013-01-12 20:07:06188 expect: '{ a: 1 }' },
189 { client: client_unix, send: 'url.format("http://google.com")',
190 expect: 'http://google.com/' },
191 { client: client_unix, send: 'var path = 42; path',
Sakthipriyan Vairamani77fa3852015-07-12 00:53:39192 expect: '42' },
193 // this makes sure that we don't print `undefined` when we actually print
194 // the error message
195 { client: client_unix, send: '.invalid_repl_command',
196 expect: 'Invalid REPL keyword\n' + prompt_unix },
Sakthipriyan Vairamani30edb5a2015-07-12 00:58:20197 // this makes sure that we don't crash when we use an inherited property as
198 // a REPL command
199 { client: client_unix, send: '.toString',
200 expect: 'Invalid REPL keyword\n' + prompt_unix },
Sakthipriyan Vairamani81ea52a2015-07-12 01:22:33201 // fail when we are not inside a String and a line continuation is used
202 { client: client_unix, send: '[] \\',
203 expect: /^SyntaxError: Unexpected token ILLEGAL/ },
204 // do not fail when a String is created with line continuation
205 { client: client_unix, send: '\'the\\\nfourth\\\neye\'',
206 expect: prompt_multiline + prompt_multiline +
207 '\'thefourtheye\'\n' + prompt_unix },
208 // Don't fail when a partial String is created and line continuation is used
209 // with whitespace characters at the end of the string. We are to ignore it.
210 // This test is to make sure that we properly remove the whitespace
211 // characters at the end of line, unlike the buggy `trimWhitespace` function
212 { client: client_unix, send: ' \t .break \t ',
213 expect: prompt_unix },
214 // multiline strings preserve whitespace characters in them
215 { client: client_unix, send: '\'the \\\n fourth\t\t\\\n eye \'',
216 expect: prompt_multiline + prompt_multiline +
217 '\'the fourth\\t\\t eye \'\n' + prompt_unix },
218 // more than one multiline strings also should preserve whitespace chars
219 { client: client_unix, send: '\'the \\\n fourth\' + \'\t\t\\\n eye \'',
220 expect: prompt_multiline + prompt_multiline +
221 '\'the fourth\\t\\t eye \'\n' + prompt_unix },
222 // using REPL commands within a string literal should still work
223 { client: client_unix, send: '\'\\\n.break',
224 expect: prompt_unix },
225 // using REPL command "help" within a string literal should still work
226 { client: client_unix, send: '\'thefourth\\\n.help\neye\'',
227 expect: /'thefourtheye'/ },
Sakthipriyan Vairamaniafd7e372015-07-12 21:48:50228 // empty lines in the REPL should be allowed
229 { client: client_unix, send: '\n\r\n\r\n',
230 expect: prompt_unix + prompt_unix + prompt_unix },
231 // empty lines in the string literals should not affect the string
232 { client: client_unix, send: '\'the\\\n\\\nfourtheye\'\n',
233 expect: prompt_multiline + prompt_multiline +
234 '\'thefourtheye\'\n' + prompt_unix },
cjihriga69ab272015-08-13 16:14:34235 // Regression test for https://github.com/nodejs/node/issues/597
Sakthipriyan Vairamaniea05e762015-07-08 21:53:48236 { client: client_unix,
237 send: '/(.)(.)(.)(.)(.)(.)(.)(.)(.)/.test(\'123456789\')\n',
238 expect: `true\n${prompt_unix}` },
239 // the following test's result depends on the RegEx's match from the above
240 { client: client_unix,
241 send: 'RegExp.$1\nRegExp.$2\nRegExp.$3\nRegExp.$4\nRegExp.$5\n' +
242 'RegExp.$6\nRegExp.$7\nRegExp.$8\nRegExp.$9\n',
243 expect: ['\'1\'\n', '\'2\'\n', '\'3\'\n', '\'4\'\n', '\'5\'\n', '\'6\'\n',
244 '\'7\'\n', '\'8\'\n', '\'9\'\n'].join(`${prompt_unix}`) },
Ryan Dahl08d81162010-12-01 21:43:05245 ]);
Marco Rogers118b88e2010-11-20 23:44:58246}
247
Matt Ranneyb7441042010-04-11 23:13:32248function tcp_test() {
Oleg Efimov0ce9cba2010-12-04 22:45:52249 server_tcp = net.createServer(function(socket) {
Matt Ranneyb7441042010-04-11 23:13:32250 assert.strictEqual(server_tcp, socket.server);
Ryan Dahla6942b32010-06-08 00:39:24251
Ben Noordhuis018e1102011-10-14 23:08:36252 socket.on('end', function() {
Matt Ranneyb7441042010-04-11 23:13:32253 socket.end();
254 });
255
256 repl.start(prompt_tcp, socket);
257 });
258
Oleg Efimov0ce9cba2010-12-04 22:45:52259 server_tcp.listen(common.PORT, function() {
260 var read_buffer = '';
Ryan Dahla6942b32010-06-08 00:39:24261
Ryan Dahl9fd5e3c2010-07-15 18:47:25262 client_tcp = net.createConnection(common.PORT);
Matt Ranneyb7441042010-04-11 23:13:32263
Ben Noordhuis018e1102011-10-14 23:08:36264 client_tcp.on('connect', function() {
Matt Ranneyb7441042010-04-11 23:13:32265 assert.equal(true, client_tcp.readable);
266 assert.equal(true, client_tcp.writable);
267
268 send_expect([
Oleg Efimov0665f022010-12-05 19:15:30269 { client: client_tcp, send: '',
270 expect: prompt_tcp },
Nathan Rajlichaab7cb72012-04-06 19:20:01271 { client: client_tcp, send: 'invoke_me(333)',
Oleg Efimov0665f022010-12-05 19:15:30272 expect: ('\'' + 'invoked 333' + '\'\n' + prompt_tcp) },
Nathan Rajlichaab7cb72012-04-06 19:20:01273 { client: client_tcp, send: 'a += 1',
Oleg Efimov0665f022010-12-05 19:15:30274 expect: ('12346' + '\n' + prompt_tcp) },
275 { client: client_tcp,
Nathan Rajlichaab7cb72012-04-06 19:20:01276 send: 'require(' + JSON.stringify(moduleFilename) + ').number',
Oleg Efimov0665f022010-12-05 19:15:30277 expect: ('42' + '\n' + prompt_tcp) }
278 ]);
Matt Ranneyb7441042010-04-11 23:13:32279 });
280
Ben Noordhuis018e1102011-10-14 23:08:36281 client_tcp.on('data', function(data) {
Ryan Dahl4fe5e862010-09-06 19:12:36282 read_buffer += data.toString('ascii', 0, data.length);
isaacs4631c502013-08-28 01:53:39283 console.error('TCP data: ' + JSON.stringify(read_buffer) +
Oleg Efimov0ce9cba2010-12-04 22:45:52284 ', expecting ' + JSON.stringify(client_tcp.expect));
Matt Ranneyafe3c1c2010-04-12 21:29:49285 if (read_buffer.indexOf(prompt_tcp) !== -1) {
286 assert.strictEqual(client_tcp.expect, read_buffer);
isaacs4631c502013-08-28 01:53:39287 console.error('match');
Oleg Efimov0ce9cba2010-12-04 22:45:52288 read_buffer = '';
Matt Ranneyafe3c1c2010-04-12 21:29:49289 if (client_tcp.list && client_tcp.list.length > 0) {
290 send_expect(client_tcp.list);
Ryan Dahl08d81162010-12-01 21:43:05291 } else {
isaacs4631c502013-08-28 01:53:39292 console.error('End of TCP test.\n');
Marco Rogers118b88e2010-11-20 23:44:58293 clean_up();
Matt Ranneyafe3c1c2010-04-12 21:29:49294 }
Ryan Dahl08d81162010-12-01 21:43:05295 } else {
isaacs4631c502013-08-28 01:53:39296 console.error('didn\'t see prompt yet, buffering');
Matt Ranneyb7441042010-04-11 23:13:32297 }
298 });
Ryan Dahla6942b32010-06-08 00:39:24299
Ben Noordhuis018e1102011-10-14 23:08:36300 client_tcp.on('error', function(e) {
Matt Ranneyb7441042010-04-11 23:13:32301 throw e;
302 });
Ryan Dahla6942b32010-06-08 00:39:24303
Ben Noordhuis018e1102011-10-14 23:08:36304 client_tcp.on('close', function() {
Matt Ranneyb7441042010-04-11 23:13:32305 server_tcp.close();
306 });
307 });
308
Matt Ranneyb7441042010-04-11 23:13:32309}
310
311function unix_test() {
Oleg Efimov0ce9cba2010-12-04 22:45:52312 server_unix = net.createServer(function(socket) {
Matt Ranneyb7441042010-04-11 23:13:32313 assert.strictEqual(server_unix, socket.server);
Matt Ranneyb7441042010-04-11 23:13:32314
Ben Noordhuis018e1102011-10-14 23:08:36315 socket.on('end', function() {
Matt Ranneyb7441042010-04-11 23:13:32316 socket.end();
317 });
318
Fedor Indutny1a52d6a2014-07-31 08:12:18319 repl.start({
Nathan Rajlichb1e78ce2012-10-12 23:34:36320 prompt: prompt_unix,
321 input: socket,
322 output: socket,
323 useGlobal: true
Fedor Indutny1a52d6a2014-07-31 08:12:18324 }).context.message = message;
Matt Ranneyb7441042010-04-11 23:13:32325 });
326
Ben Noordhuis018e1102011-10-14 23:08:36327 server_unix.on('listening', function() {
Oleg Efimov0ce9cba2010-12-04 22:45:52328 var read_buffer = '';
Ryan Dahla6942b32010-06-08 00:39:24329
Ryan Dahl03a119e2011-08-09 23:06:32330 client_unix = net.createConnection(common.PIPE);
Matt Ranneyb7441042010-04-11 23:13:32331
Ben Noordhuis018e1102011-10-14 23:08:36332 client_unix.on('connect', function() {
Matt Ranneyb7441042010-04-11 23:13:32333 assert.equal(true, client_unix.readable);
334 assert.equal(true, client_unix.writable);
335
336 send_expect([
Oleg Efimov0665f022010-12-05 19:15:30337 { client: client_unix, send: '',
338 expect: prompt_unix },
Nathan Rajlichaab7cb72012-04-06 19:20:01339 { client: client_unix, send: 'message',
Oleg Efimov0665f022010-12-05 19:15:30340 expect: ('\'' + message + '\'\n' + prompt_unix) },
Nathan Rajlichaab7cb72012-04-06 19:20:01341 { client: client_unix, send: 'invoke_me(987)',
Oleg Efimov0665f022010-12-05 19:15:30342 expect: ('\'' + 'invoked 987' + '\'\n' + prompt_unix) },
Nathan Rajlichaab7cb72012-04-06 19:20:01343 { client: client_unix, send: 'a = 12345',
Ryan Dahl8b352bd2011-01-02 05:14:06344 expect: ('12345' + '\n' + prompt_unix) },
Nathan Rajlichaab7cb72012-04-06 19:20:01345 { client: client_unix, send: '{a:1}',
Colton Baker87286cc2011-10-04 22:08:18346 expect: ('{ a: 1 }' + '\n' + prompt_unix) }
Oleg Efimov0665f022010-12-05 19:15:30347 ]);
Matt Ranneyb7441042010-04-11 23:13:32348 });
349
Ben Noordhuis018e1102011-10-14 23:08:36350 client_unix.on('data', function(data) {
Ryan Dahl4fe5e862010-09-06 19:12:36351 read_buffer += data.toString('ascii', 0, data.length);
isaacs4631c502013-08-28 01:53:39352 console.error('Unix data: ' + JSON.stringify(read_buffer) +
Oleg Efimov0ce9cba2010-12-04 22:45:52353 ', expecting ' + JSON.stringify(client_unix.expect));
Matt Ranneyafe3c1c2010-04-12 21:29:49354 if (read_buffer.indexOf(prompt_unix) !== -1) {
355 assert.strictEqual(client_unix.expect, read_buffer);
isaacs4631c502013-08-28 01:53:39356 console.error('match');
Oleg Efimov0ce9cba2010-12-04 22:45:52357 read_buffer = '';
Matt Ranneyafe3c1c2010-04-12 21:29:49358 if (client_unix.list && client_unix.list.length > 0) {
359 send_expect(client_unix.list);
Ryan Dahla6942b32010-06-08 00:39:24360 } else {
isaacs4631c502013-08-28 01:53:39361 console.error('End of Unix test, running Error test.\n');
Marco Rogers118b88e2010-11-20 23:44:58362 process.nextTick(error_test);
Matt Ranneyafe3c1c2010-04-12 21:29:49363 }
Ryan Dahl08d81162010-12-01 21:43:05364 } else {
isaacs4631c502013-08-28 01:53:39365 console.error('didn\'t see prompt yet, buffering.');
Matt Ranneyb7441042010-04-11 23:13:32366 }
367 });
Ryan Dahla6942b32010-06-08 00:39:24368
Ben Noordhuis018e1102011-10-14 23:08:36369 client_unix.on('error', function(e) {
Matt Ranneyb7441042010-04-11 23:13:32370 throw e;
371 });
372
Ben Noordhuis018e1102011-10-14 23:08:36373 client_unix.on('close', function() {
Matt Ranneyb7441042010-04-11 23:13:32374 server_unix.close();
375 });
376 });
377
Ryan Dahl03a119e2011-08-09 23:06:32378 server_unix.listen(common.PIPE);
Matt Ranneyb7441042010-04-11 23:13:32379}
380
381unix_test();
Marco Rogers118b88e2010-11-20 23:44:58382
Oleg Efimov0ce9cba2010-12-04 22:45:52383timer = setTimeout(function() {
384 assert.fail('Timeout');
Ryan Dahl129217a2011-01-26 01:35:06385}, 5000);