Skip to content

Commit

Permalink
test: fix flaky test-force-repl
Browse files Browse the repository at this point in the history
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: #8483
PR-URL: #8484
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and Myles Borins committed Oct 10, 2016
1 parent 566f3b9 commit 7d6ce04
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions test/parallel/test-force-repl.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
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)
var cp = spawn(process.execPath, ['-i']);
var gotToEnd = false;
const cp = spawn(process.execPath, ['-i']);
var timeoutId = setTimeout(function() {
throw new Error('timeout!');
}, common.platformTimeout(1000)); // give node + the repl 1 second to boot up
common.fail('timeout!');
}, common.platformTimeout(5000)); // give node + the repl 5 seconds to start

cp.stdout.setEncoding('utf8');

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

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

0 comments on commit 7d6ce04

Please sign in to comment.