summaryrefslogtreecommitdiff
path: root/test/parallel/test-repl.js
blob: 7e426eb54ee51c4ca7b539b3e87886691260efd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

/* eslint-disable max-len, strict */
'use strict';
const common = require('../common');
const assert = require('assert');

common.globalCheck = false;
common.refreshTmpDir();

const net = require('net');
const repl = require('repl');
const message = 'Read, Eval, Print Loop';
const prompt_unix = 'node via Unix socket> ';
const prompt_tcp = 'node via TCP socket> ';
const prompt_multiline = '... ';
const prompt_npm = 'npm should be run outside of the ' +
                   'node repl, in your normal shell.\n' +
                   '(Press Control-D to exit.)\n';
const expect_npm = prompt_npm + prompt_unix;
let server_tcp, server_unix, client_tcp, client_unix, replServer;


// absolute path to test/fixtures/a.js
const moduleFilename = require('path').join(common.fixturesDir, 'a');

console.error('repl test');

// function for REPL to run
global.invoke_me = function(arg) {
  return 'invoked ' + arg;
};

function send_expect(list) {
  if (list.length > 0) {
    const cur = list.shift();

    console.error('sending ' + JSON.stringify(cur.send));

    cur.client.expect = cur.expect;
    cur.client.list = list;
    if (cur.send.length > 0) {
      cur.client.write(cur.send + '\n');
    }
  }
}

function clean_up() {
  client_tcp.end();
  client_unix.end();
}

function strict_mode_error_test() {
  send_expect([
    { client: client_unix, send: 'ref = 1',
      expect: /^ReferenceError:\sref\sis\snot\sdefined\n\s+at\srepl:1:5/ },
  ]);
}

function error_test() {
  // The other stuff is done so reuse unix socket
  let read_buffer = '';
  let run_strict_test = true;
  client_unix.removeAllListeners('data');

  client_unix.on('data', function(data) {
    read_buffer += data.toString('ascii', 0, data.length);
    console.error('Unix data: ' + JSON.stringify(read_buffer) + ', expecting ' +
                 (client_unix.expect.exec ?
                  client_unix.expect :
                  JSON.stringify(client_unix.expect)));

    if (read_buffer.indexOf(prompt_unix) !== -1) {
      // if it's an exact match, then don't do the regexp
      if (read_buffer !== client_unix.expect) {
        let expect = client_unix.expect;
        if (expect === prompt_multiline)
          expect = /[.]{3} /;
        assert.ok(read_buffer.match(expect));
        console.error('match');
      }
      read_buffer = '';
      if (client_unix.list && client_unix.list.length > 0) {
        send_expect(client_unix.list);
      } else if (run_strict_test) {
        replServer.replMode = repl.REPL_MODE_STRICT;
        run_strict_test = false;
        strict_mode_error_test();
      } else {
        console.error('End of Error test, running TCP test.');
        tcp_test();
      }

    } else if (read_buffer.indexOf(prompt_multiline) !== -1) {
      // Check that you meant to send a multiline test
      assert.strictEqual(prompt_multiline, client_unix.expect);
      read_buffer = '';
      if (client_unix.list && client_unix.list.length > 0) {
        send_expect(client_unix.list);
      } else if (run_strict_test) {
        replServer.replMode = repl.REPL_MODE_STRICT;
        run_strict_test = false;
        strict_mode_error_test();
      } else {
        console.error('End of Error test, running TCP test.\n');
        tcp_test();
      }

    } else {
      console.error('didn\'t see prompt yet, buffering.');
    }
  });

  send_expect([
    // Uncaught error throws and prints out
    { client: client_unix, send: 'throw new Error(\'test error\');',
      expect: /^Error: test error/ },
    // Common syntax error is treated as multiline command
    { client: client_unix, send: 'function test_func() {',
      expect: prompt_multiline },
    // You can recover with the .break command
    { client: client_unix, send: '.break',
      expect: prompt_unix },
    // But passing the same string to eval() should throw
    { client: client_unix, send: 'eval("function test_func() {")',
      expect: /\bSyntaxError: Unexpected end of input/ },
    // Can handle multiline template literals
    { client: client_unix, send: '`io.js',
      expect: prompt_multiline },
    // Special REPL commands still available
    { client: client_unix, send: '.break',
      expect: prompt_unix },
    // Template expressions can cross lines
    { client: client_unix, send: '`io.js ${"1.0"',
      expect: prompt_multiline },
    { client: client_unix, send: '+ ".2"}`',
      expect: `'io.js 1.0.2'\n${prompt_unix}` },
    // Dot prefix in multiline commands aren't treated as commands
    { client: client_unix, send: '("a"',
      expect: prompt_multiline },
    { client: client_unix, send: '.charAt(0))',
      expect: `'a'\n${prompt_unix}` },
    // Floating point numbers are not interpreted as REPL commands.
    { client: client_unix, send: '.1234',
      expect: '0.1234' },
    // Floating point expressions are not interpreted as REPL commands
    { client: client_unix, send: '.1+.1',
      expect: '0.2' },
    // Can parse valid JSON
    { client: client_unix, send: 'JSON.parse(\'{"valid": "json"}\');',
      expect: '{ valid: \'json\' }'},
    // invalid input to JSON.parse error is special case of syntax error,
    // should throw
    { client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',
      expect: /\bSyntaxError: Unexpected token i/ },
    // end of input to JSON.parse error is special case of syntax error,
    // should throw
    { client: client_unix, send: 'JSON.parse(\'066\');',
      expect: /\bSyntaxError: Unexpected number/ },
    // should throw
    { client: client_unix, send: 'JSON.parse(\'{\');',
      expect: /\bSyntaxError: Unexpected end of JSON input/ },
    // invalid RegExps are a special case of syntax error,
    // should throw
    { client: client_unix, send: '/(/;',
      expect: /\bSyntaxError: Invalid regular expression:/ },
    // invalid RegExp modifiers are a special case of syntax error,
    // should throw (GH-4012)
    { client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
      expect: /\bSyntaxError: Invalid flags supplied to RegExp constructor/ },
    // strict mode syntax errors should be caught (GH-5178)
    { client: client_unix,
      send: '(function() { "use strict"; return 0755; })()',
      expect: /\bSyntaxError: Octal literals are not allowed in strict mode/ },
    {
      client: client_unix,
      send: '(function(a, a, b) { "use strict"; return a + b + c; })()',
      expect: /\bSyntaxError: Duplicate parameter name not allowed in this context/ // eslint-disable-line max-len
    },
    {
      client: client_unix,
      send: '(function() { "use strict"; with (this) {} })()',
      expect: /\bSyntaxError: Strict mode code may not include a with statement/
    },
    {
      client: client_unix,
      send: '(function() { "use strict"; var x; delete x; })()',
      expect: /\bSyntaxError: Delete of an unqualified identifier in strict mode/ // eslint-disable-line max-len
    },
    { client: client_unix,
      send: '(function() { "use strict"; eval = 17; })()',
      expect: /\bSyntaxError: Unexpected eval or arguments in strict mode/ },
    {
      client: client_unix,
      send: '(function() { "use strict"; if (true) function f() { } })()',
      expect: /\bSyntaxError: In strict mode code, functions can only be declared at top level or inside a block./ // eslint-disable-line max-len
    },
    // Named functions can be used:
    { client: client_unix, send: 'function blah() { return 1; }',
      expect: prompt_unix },
    { client: client_unix, send: 'blah()',
      expect: '1\n' + prompt_unix },
    // Functions should not evaluate twice (#2773)
    { client: client_unix, send: 'var I = [1,2,3,function() {}]; I.pop()',
      expect: '[Function]' },
    // Multiline object
    { client: client_unix, send: '{ a: ',
      expect: prompt_multiline },
    { client: client_unix, send: '1 }',
      expect: '{ a: 1 }' },
    // Multiline anonymous function with comment
    { client: client_unix, send: '(function() {',
      expect: prompt_multiline },
    { client: client_unix, send: '// blah',
      expect: prompt_multiline },
    { client: client_unix, send: 'return 1;',
      expect: prompt_multiline },
    { client: client_unix, send: '})()',
      expect: '1' },
    // Multiline function call
    { client: client_unix, send: 'function f(){}; f(f(1,',
      expect: prompt_multiline },
    { client: client_unix, send: '2)',
      expect: prompt_multiline },
    { client: client_unix, send: ')',
      expect: 'undefined\n' + prompt_unix },
    // npm prompt error message
    { client: client_unix, send: 'npm install foobar',
      expect: expect_npm },
    { client: client_unix, send: '(function() {\n\nreturn 1;\n})()',
      expect: '1' },
    { client: client_unix, send: '{\n\na: 1\n}',
      expect: '{ a: 1 }' },
    { client: client_unix, send: 'url.format("http://google.com")',
      expect: 'http://google.com/' },
    { client: client_unix, send: 'var path = 42; path',
      expect: '42' },
    // this makes sure that we don't print `undefined` when we actually print
    // the error message
    { client: client_unix, send: '.invalid_repl_command',
      expect: 'Invalid REPL keyword\n' + prompt_unix },
    // this makes sure that we don't crash when we use an inherited property as
    // a REPL command
    { client: client_unix, send: '.toString',
      expect: 'Invalid REPL keyword\n' + prompt_unix },
    // fail when we are not inside a String and a line continuation is used
    { client: client_unix, send: '[] \\',
      expect: /\bSyntaxError: Invalid or unexpected token/ },
    // do not fail when a String is created with line continuation
    { client: client_unix, send: '\'the\\\nfourth\\\neye\'',
      expect: prompt_multiline + prompt_multiline +
              '\'thefourtheye\'\n' + prompt_unix },
    // Don't fail when a partial String is created and line continuation is used
    // with whitespace characters at the end of the string. We are to ignore it.
    // This test is to make sure that we properly remove the whitespace
    // characters at the end of line, unlike the buggy `trimWhitespace` function
    { client: client_unix, send: '  \t    .break  \t  ',
      expect: prompt_unix },
    // multiline strings preserve whitespace characters in them
    { client: client_unix, send: '\'the \\\n   fourth\t\t\\\n  eye  \'',
      expect: prompt_multiline + prompt_multiline +
              '\'the    fourth\\t\\t  eye  \'\n' + prompt_unix },
    // more than one multiline strings also should preserve whitespace chars
    { client: client_unix, send: '\'the \\\n   fourth\' +  \'\t\t\\\n  eye  \'',
      expect: prompt_multiline + prompt_multiline +
              '\'the    fourth\\t\\t  eye  \'\n' + prompt_unix },
    // using REPL commands within a string literal should still work
    { client: client_unix, send: '\'\\\n.break',
      expect: prompt_unix },
    // using REPL command "help" within a string literal should still work
    { client: client_unix, send: '\'thefourth\\\n.help\neye\'',
      expect: /'thefourtheye'/ },
    // empty lines in the REPL should be allowed
    { client: client_unix, send: '\n\r\n\r\n',
      expect: prompt_unix + prompt_unix + prompt_unix },
    // empty lines in the string literals should not affect the string
    { client: client_unix, send: '\'the\\\n\\\nfourtheye\'\n',
      expect: prompt_multiline + prompt_multiline +
              '\'thefourtheye\'\n' + prompt_unix },
    // Regression test for https://github.com/nodejs/node/issues/597
    { client: client_unix,
      send: '/(.)(.)(.)(.)(.)(.)(.)(.)(.)/.test(\'123456789\')\n',
      expect: `true\n${prompt_unix}` },
    // the following test's result depends on the RegEx's match from the above
    { client: client_unix,
      send: 'RegExp.$1\nRegExp.$2\nRegExp.$3\nRegExp.$4\nRegExp.$5\n' +
            'RegExp.$6\nRegExp.$7\nRegExp.$8\nRegExp.$9\n',
      expect: ['\'1\'\n', '\'2\'\n', '\'3\'\n', '\'4\'\n', '\'5\'\n', '\'6\'\n',
               '\'7\'\n', '\'8\'\n', '\'9\'\n'].join(`${prompt_unix}`) },
    // regression tests for https://github.com/nodejs/node/issues/2749
    { client: client_unix, send: 'function x() {\nreturn \'\\n\';\n }',
      expect: prompt_multiline + prompt_multiline +
              'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x() {\nreturn \'\\\\\';\n }',
      expect: prompt_multiline + prompt_multiline +
              'undefined\n' + prompt_unix },
    // regression tests for https://github.com/nodejs/node/issues/3421
    { client: client_unix, send: 'function x() {\n//\'\n }',
      expect: prompt_multiline + prompt_multiline +
              'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x() {\n//"\n }',
      expect: prompt_multiline + prompt_multiline +
              'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x() {//\'\n }',
      expect: prompt_multiline + 'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x() {//"\n }',
      expect: prompt_multiline + 'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x() {\nvar i = "\'";\n }',
      expect: prompt_multiline + prompt_multiline +
              'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x(/*optional*/) {}',
      expect: 'undefined\n' + prompt_unix },
    { client: client_unix, send: 'function x(/* // 5 */) {}',
      expect: 'undefined\n' + prompt_unix },
    { client: client_unix, send: '// /* 5 */',
      expect: 'undefined\n' + prompt_unix },
    { client: client_unix, send: '"//"',
      expect: '\'//\'\n' + prompt_unix },
    { client: client_unix, send: '"data /*with*/ comment"',
      expect: '\'data /*with*/ comment\'\n' + prompt_unix },
    { client: client_unix, send: 'function x(/*fn\'s optional params*/) {}',
      expect: 'undefined\n' + prompt_unix },
    { client: client_unix, send: '/* \'\n"\n\'"\'\n*/',
      expect: 'undefined\n' + prompt_unix },
    // REPL should get a normal require() function, not one that allows
    // access to internal modules without the --expose_internals flag.
    { client: client_unix, send: 'require("internal/repl")',
      expect: /^Error: Cannot find module 'internal\/repl'/ },
    // REPL should handle quotes within regexp literal in multiline mode
    { client: client_unix,
      send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
      expect: prompt_multiline + prompt_multiline +
            'undefined\n' + prompt_unix },
    { client: client_unix,
      send: "function x(s) {\nreturn s.replace(/'/,'');\n}",
      expect: prompt_multiline + prompt_multiline +
            'undefined\n' + prompt_unix },
    { client: client_unix,
      send: 'function x(s) {\nreturn s.replace(/"/,"");\n}',
      expect: prompt_multiline + prompt_multiline +
            'undefined\n' + prompt_unix },
    { client: client_unix,
      send: 'function x(s) {\nreturn s.replace(/.*/,"");\n}',
      expect: prompt_multiline + prompt_multiline +
            'undefined\n' + prompt_unix },
    { client: client_unix, send: '{ var x = 4; }',
      expect: 'undefined\n' + prompt_unix },
    // Illegal token is not recoverable outside string literal, RegExp literal,
    // or block comment. https://github.com/nodejs/node/issues/3611
    { client: client_unix, send: 'a = 3.5e',
      expect: /\bSyntaxError: Invalid or unexpected token/ },
    // Mitigate https://github.com/nodejs/node/issues/548
    { client: client_unix, send: 'function name(){ return "node"; };name()',
      expect: "'node'\n" + prompt_unix },
    { client: client_unix, send: 'function name(){ return "nodejs"; };name()',
      expect: "'nodejs'\n" + prompt_unix },
    // Avoid emitting repl:line-number for SyntaxError
    { client: client_unix, send: 'a = 3.5e',
      expect: /^(?!repl)/ },
    // Avoid emitting stack trace
    { client: client_unix, send: 'a = 3.5e',
      expect: /^(?!\s+at\s)/gm },

    // https://github.com/nodejs/node/issues/9850
    { client: client_unix, send: 'function* foo() {}; foo().next();',
      expect: '{ value: undefined, done: true }' },

    { client: client_unix, send: 'function *foo() {}; foo().next();',
      expect: '{ value: undefined, done: true }' },

    { client: client_unix, send: 'function*foo() {}; foo().next();',
      expect: '{ value: undefined, done: true }' },

    { client: client_unix, send: 'function * foo() {}; foo().next()',
      expect: '{ value: undefined, done: true }' },

    // https://github.com/nodejs/node/issues/9300
    {
      client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}',
      expect: `${prompt_multiline}${prompt_multiline}undefined\n${prompt_unix}`
    },

    {
      client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())',
      expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix
    },

    {
      client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())',
      expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix
    }
  ]);
}

function tcp_test() {
  server_tcp = net.createServer(function(socket) {
    assert.strictEqual(server_tcp, socket.server);

    socket.on('end', function() {
      socket.end();
    });

    repl.start(prompt_tcp, socket);
  });

  server_tcp.listen(0, function() {
    let read_buffer = '';

    client_tcp = net.createConnection(this.address().port);

    client_tcp.on('connect', function() {
      assert.strictEqual(true, client_tcp.readable);
      assert.strictEqual(true, client_tcp.writable);

      send_expect([
        { client: client_tcp, send: '',
          expect: prompt_tcp },
        { client: client_tcp, send: 'invoke_me(333)',
          expect: ('\'' + 'invoked 333' + '\'\n' + prompt_tcp) },
        { client: client_tcp, send: 'a += 1',
          expect: ('12346' + '\n' + prompt_tcp) },
        { client: client_tcp,
          send: 'require(' + JSON.stringify(moduleFilename) + ').number',
          expect: ('42' + '\n' + prompt_tcp) }
      ]);
    });

    client_tcp.on('data', function(data) {
      read_buffer += data.toString('ascii', 0, data.length);
      console.error('TCP data: ' + JSON.stringify(read_buffer) +
                   ', expecting ' + JSON.stringify(client_tcp.expect));
      if (read_buffer.indexOf(prompt_tcp) !== -1) {
        assert.strictEqual(client_tcp.expect, read_buffer);
        console.error('match');
        read_buffer = '';
        if (client_tcp.list && client_tcp.list.length > 0) {
          send_expect(client_tcp.list);
        } else {
          console.error('End of TCP test.\n');
          clean_up();
        }
      } else {
        console.error('didn\'t see prompt yet, buffering');
      }
    });

    client_tcp.on('error', function(e) {
      throw e;
    });

    client_tcp.on('close', function() {
      server_tcp.close();
    });
  });

}

function unix_test() {
  server_unix = net.createServer(function(socket) {
    assert.strictEqual(server_unix, socket.server);

    socket.on('end', function() {
      socket.end();
    });

    replServer = repl.start({
      prompt: prompt_unix,
      input: socket,
      output: socket,
      useGlobal: true
    });
    replServer.context.message = message;
  });

  server_unix.on('listening', function() {
    let read_buffer = '';

    client_unix = net.createConnection(common.PIPE);

    client_unix.on('connect', function() {
      assert.strictEqual(true, client_unix.readable);
      assert.strictEqual(true, client_unix.writable);

      send_expect([
        { client: client_unix, send: '',
          expect: prompt_unix },
        { client: client_unix, send: 'message',
          expect: ('\'' + message + '\'\n' + prompt_unix) },
        { client: client_unix, send: 'invoke_me(987)',
          expect: ('\'' + 'invoked 987' + '\'\n' + prompt_unix) },
        { client: client_unix, send: 'a = 12345',
          expect: ('12345' + '\n' + prompt_unix) },
        { client: client_unix, send: '{a:1}',
          expect: ('{ a: 1 }' + '\n' + prompt_unix) }
      ]);
    });

    client_unix.on('data', function(data) {
      read_buffer += data.toString('ascii', 0, data.length);
      console.error('Unix data: ' + JSON.stringify(read_buffer) +
                   ', expecting ' + JSON.stringify(client_unix.expect));
      if (read_buffer.indexOf(prompt_unix) !== -1) {
        assert.strictEqual(client_unix.expect, read_buffer);
        console.error('match');
        read_buffer = '';
        if (client_unix.list && client_unix.list.length > 0) {
          send_expect(client_unix.list);
        } else {
          console.error('End of Unix test, running Error test.\n');
          process.nextTick(error_test);
        }
      } else {
        console.error('didn\'t see prompt yet, buffering.');
      }
    });

    client_unix.on('error', function(e) {
      throw e;
    });

    client_unix.on('close', function() {
      server_unix.close();
    });
  });

  server_unix.listen(common.PIPE);
}

unix_test();