diff --git a/lib/fork.js b/lib/fork.js index 90b087a7e..25bef8ff9 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -78,11 +78,15 @@ module.exports = function (file, opts) { send(ps, 'teardown'); }); - ps.on('exit', function (code) { + ps.on('exit', function (code, signal) { if (code > 0) { return reject(new AvaError(relFile + ' exited with a non-zero exit code: ' + code)); } + if (code === null && signal) { + return reject(new AvaError(relFile + ' exited due to ' + signal)); + } + if (results) { resolve(results); } else { diff --git a/test/fork.js b/test/fork.js index 6a553a2a4..274f6ddc3 100644 --- a/test/fork.js +++ b/test/fork.js @@ -76,6 +76,18 @@ test('rejects promise if the process exits without results', function (t) { }); }); +test('rejects promise if the process is killed', function (t) { + var forked = fork(fixture('es2015.js')); + return forked + .on('stats', function () { + this.kill('SIGKILL'); + }) + .catch(function (err) { + t.is(err.name, 'AvaError'); + t.is(err.message, path.join('test', 'fixture', 'es2015.js') + ' exited due to SIGKILL'); + }); +}); + test('fake timers do not break duration', function (t) { fork(fixture('fake-timers.js')) .run({})