diff --git a/core/test/functional/routes/admin_test.js b/core/test/functional/routes/admin_test.js index 12cb9b13b5..7e364b4b03 100644 --- a/core/test/functional/routes/admin_test.js +++ b/core/test/functional/routes/admin_test.js @@ -126,6 +126,8 @@ describe('Admin Routing', function () { after(function (done) { if (forkedGhost) { forkedGhost.kill(done); + } else { + done(new Error('No forked ghost process exists, test setup must have failed.')); } }); @@ -162,6 +164,8 @@ describe('Admin Routing', function () { after(function (done) { if (forkedGhost) { forkedGhost.kill(done); + } else { + done(new Error('No forked ghost process exists, test setup must have failed.')); } }); diff --git a/core/test/functional/routes/frontend_test.js b/core/test/functional/routes/frontend_test.js index 79a5e9fafb..dd31de4cbf 100644 --- a/core/test/functional/routes/frontend_test.js +++ b/core/test/functional/routes/frontend_test.js @@ -707,6 +707,8 @@ describe('Frontend Routing', function () { after(function (done) { if (forkedGhost) { forkedGhost.kill(done); + } else { + done(new Error('No forked ghost process exists, test setup must have failed.')); } }); diff --git a/core/test/utils/fork.js b/core/test/utils/fork.js index 4d69af4b87..218f219fe4 100644 --- a/core/test/utils/fork.js +++ b/core/test/utils/fork.js @@ -96,7 +96,8 @@ function forkGhost(newConfig, envName) { /*jshint unused:false*/ pingTries = pingTries + 1; // continue checking - if (pingTries >= 20 && pingStop()) { + if (pingTries >= 50 && pingStop()) { + child.kill(); reject(new Error('Timed out waiting for child process')); } }); @@ -105,11 +106,14 @@ function forkGhost(newConfig, envName) { child.on('exit', function (code, signal) { /*jshint unused:false*/ child.exited = true; + + fs.unlink(newConfigFile, function () { + // swallow any errors -- file may not exist if fork() failed + }); + if (pingStop()) { reject(new Error('Child process exit code: ' + code)); } - // cleanup the temporary config file - fs.unlink(newConfigFile); }); // override kill() to have an async callback