diff --git a/appveyor.yml b/appveyor.yml index e1f7cc13b..0980da796 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,9 @@ environment: matrix: + - nodejs_version: '0.10' - nodejs_version: '5' - nodejs_version: '4' - nodejs_version: '0.12' - - nodejs_version: '0.10' install: - ps: Install-Product node $env:nodejs_version - set CI=true diff --git a/lib/babel.js b/lib/babel.js index dd68e7922..8c47e3a98 100644 --- a/lib/babel.js +++ b/lib/babel.js @@ -60,29 +60,19 @@ process.on('message', function (message) { }); process.on('ava-exit', function () { - // use a little delay when running on AppVeyor (because it's shit) - var delay = process.env.AVA_APPVEYOR ? 100 : 0; - - setTimeout(function () { - process.exit(0); - }, delay); + process.exit(0); }); process.on('ava-teardown', function () { var rejections = loudRejection.currentlyUnhandled(); - if (rejections.length === 0) { - return exit(); - } - - rejections = rejections.map(function (rejection) { - return serializeValue(rejection.reason); - }); + if (rejections.length !== 0) { + rejections = rejections.map(function (rejection) { + return serializeValue(rejection.reason); + }); - send('unhandledRejections', {rejections: rejections}); - setTimeout(exit, 100); -}); + send('unhandledRejections', {rejections: rejections}); + } -function exit() { send('teardown'); -} +}); diff --git a/lib/fork.js b/lib/fork.js index 6f09ca354..b1ef265d2 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -11,6 +11,7 @@ module.exports = function (args) { var filepath = path.join(__dirname, 'babel.js'); var file = args[0]; + var exitTimer; var options = { silent: true, @@ -30,6 +31,11 @@ module.exports = function (args) { }); ps.on('exit', function (code) { + if (exitTimer) { + clearTimeout(exitTimer); + exitTimer = null; + } + if (code > 0 && code !== 143) { return reject(new Error(file + ' exited with a non-zero exit code: ' + code)); } @@ -66,7 +72,12 @@ module.exports = function (args) { // teardown finished, now exit ps.on('teardown', function () { - send(ps, 'exit'); + // use a longer delay when running on AppVeyor (because it's shit) + var delay = process.env.AVA_APPVEYOR ? 200 : 100; + + exitTimer = setTimeout(function () { + send(ps, 'exit'); + }, delay); }); // uncaught exception in fork, need to exit diff --git a/test/fork.js b/test/fork.js index 06ba2c3ee..ad9389457 100644 --- a/test/fork.js +++ b/test/fork.js @@ -8,6 +8,7 @@ function fixture(name) { } test('emits test event', function (t) { + t.plan(1); fork(fixture('generators.js')) .on('test', function (tt) { t.equal(tt.title, 'generator function'); @@ -16,6 +17,7 @@ test('emits test event', function (t) { }); test('resolves promise with tests info', function (t) { + t.plan(3); var file = fixture('generators.js'); fork(file)