From 4dfb44b3671c64b8c946a6ce8d57dd1df1b760cf Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 10 Sep 2016 10:42:05 -0700 Subject: [PATCH 1/3] 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 --- test/parallel/test-force-repl.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-force-repl.js b/test/parallel/test-force-repl.js index 5907dc2019a3a3..e90e499e58b2ca 100644 --- a/test/parallel/test-force-repl.js +++ b/test/parallel/test-force-repl.js @@ -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.platformTimeout(5000)); // give node + the repl 5 seconds to start cp.stdout.setEncoding('utf8'); -cp.stdout.once('data', function(b) { +cp.stdout.once('dasta', common.mustCall(function(b) { clearTimeout(timeoutId); assert.equal(b, '> '); - gotToEnd = true; cp.kill(); -}); - -process.on('exit', function() { - assert(gotToEnd); -}); +})); From eaafc31c8dcdc995e952228eb25047822db6a6e9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 10 Sep 2016 12:45:31 -0700 Subject: [PATCH 2/3] squash: dasta->data --- test/parallel/test-force-repl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-force-repl.js b/test/parallel/test-force-repl.js index e90e499e58b2ca..59db6469264640 100644 --- a/test/parallel/test-force-repl.js +++ b/test/parallel/test-force-repl.js @@ -11,7 +11,7 @@ var timeoutId = setTimeout(function() { cp.stdout.setEncoding('utf8'); -cp.stdout.once('dasta', common.mustCall(function(b) { +cp.stdout.once('data', common.mustCall(function(b) { clearTimeout(timeoutId); assert.equal(b, '> '); cp.kill(); From e25767ee7a28d5aa2206e75d6a83023bac79c697 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 10 Sep 2016 13:19:01 -0700 Subject: [PATCH 3/3] squash: equal->strictEqual, throw->common.fail() --- test/parallel/test-force-repl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-force-repl.js b/test/parallel/test-force-repl.js index 59db6469264640..37f2f603342a1c 100644 --- a/test/parallel/test-force-repl.js +++ b/test/parallel/test-force-repl.js @@ -6,13 +6,13 @@ 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() { - throw new Error('timeout!'); + 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.equal(b, '> '); + assert.strictEqual(b, '> '); cp.kill(); }));