Skip to content

Commit 979016f

Browse files
committed
reject test runs when forks exit with an unexpected signal
1 parent 0e8aaf3 commit 979016f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/fork.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ module.exports = function (file, opts) {
7878
send(ps, 'teardown');
7979
});
8080

81-
ps.on('exit', function (code) {
81+
ps.on('exit', function (code, signal) {
8282
if (code > 0) {
8383
return reject(new AvaError(relFile + ' exited with a non-zero exit code: ' + code));
8484
}
8585

86+
if (code === null && signal) {
87+
return reject(new AvaError(relFile + ' exited due to ' + signal));
88+
}
89+
8690
if (results) {
8791
resolve(results);
8892
} else {

test/fork.js

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ test('rejects promise if the process exits without results', function (t) {
7676
});
7777
});
7878

79+
test('rejects promise if the process is killed', function (t) {
80+
var forked = fork(fixture('es2015.js'));
81+
return forked
82+
.on('stats', function () {
83+
this.kill('SIGKILL');
84+
})
85+
.catch(function (err) {
86+
t.is(err.name, 'AvaError');
87+
t.is(err.message, 'test/fixture/es2015.js exited due to SIGKILL');
88+
});
89+
});
90+
7991
test('fake timers do not break duration', function (t) {
8092
fork(fixture('fake-timers.js'))
8193
.run({})

0 commit comments

Comments
 (0)