summaryrefslogtreecommitdiff
path: root/test/sequential/test-force-repl.js
blob: 5907dc2019a3a3b4abb4bff5906411682f90120b (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
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

// spawn a node child process in "interactive" mode (force the repl)
var cp = spawn(process.execPath, ['-i']);
var gotToEnd = false;
var timeoutId = setTimeout(function() {
  throw new Error('timeout!');
}, common.platformTimeout(1000)); // give node + the repl 1 second to boot up

cp.stdout.setEncoding('utf8');

cp.stdout.once('data', function(b) {
  clearTimeout(timeoutId);
  assert.equal(b, '> ');
  gotToEnd = true;
  cp.kill();
});

process.on('exit', function() {
  assert(gotToEnd);
});