node/test/parallel/test-force-repl.js
Rich Trott ad1a9dd35a test: fix flaky test-force-repl
Increase time allowed for startup from 1 second to 5 seconds to avoid
occasional flakiness. While at it, refactor a few minor things such as
var->const and using common.mustCall().

Fixes: https://github.com/nodejs/node/issues/8483
PR-URL: https://github.com/nodejs/node/pull/8484
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-09-13 20:35:11 -07:00

19 lines
551 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
// spawn a node child process in "interactive" mode (force the repl)
const cp = spawn(process.execPath, ['-i']);
var timeoutId = setTimeout(function() {
common.fail('timeout!');
}, common.platformTimeout(5000)); // give node + the repl 5 seconds to start
cp.stdout.setEncoding('utf8');
cp.stdout.once('data', common.mustCall(function(b) {
clearTimeout(timeoutId);
assert.strictEqual(b, '> ');
cp.kill();
}));