diff --git a/cli.js b/cli.js index 59048e663..8b01b10d3 100755 --- a/cli.js +++ b/cli.js @@ -158,7 +158,10 @@ function exit(results) { // correctly flush the output when multiple test files process.stdout.write(''); - process.exit(failed > 0 ? 1 : 0); + // timeout required to correctly flush stderr on Node 0.10 Windows + setTimeout(function () { + process.exit(failed > 0 ? 1 : 0); + }, 0); } function init(files) { diff --git a/lib/babel.js b/lib/babel.js index bdff5e78d..8f78dd45c 100644 --- a/lib/babel.js +++ b/lib/babel.js @@ -28,3 +28,9 @@ var transpiled = babel.transformFileSync(testPath, options); requireFromString(transpiled.code, testPath, { appendPaths: module.paths }); + +process.on('message', function (message) { + if (message['ava-kill-command']) { + process.exit(0); + } +}); diff --git a/lib/fork.js b/lib/fork.js index 8fadb8805..ccf80d06c 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -26,7 +26,7 @@ module.exports = function (args) { // after all tests are finished and results received // kill the forked process, so AVA can exit safely - ps.kill(); + ps.send({'ava-kill-command': true}); }); ps.on('error', reject); diff --git a/test/fork.js b/test/fork.js index a8922735c..487747cf3 100644 --- a/test/fork.js +++ b/test/fork.js @@ -48,8 +48,8 @@ test('exit after tests are finished', function (t) { fork(fixture('long-running.js')) .on('exit', function () { - t.ok(Date.now() - start < 10000, 'did NOT wait for setTimeout(fn, 15000'); - t.ok(cleanupCompleted, 'did wait for onExit(fn) to complete'); + t.ok(Date.now() - start < 10000, 'test waited for a pending setTimeout'); + t.ok(cleanupCompleted, 'cleanup did not complete'); }) .on('cleanup-completed', function (event) { cleanupCompleted = event.completed; diff --git a/test/test.js b/test/test.js index a25f30c98..bbac38010 100644 --- a/test/test.js +++ b/test/test.js @@ -12,7 +12,7 @@ function execCli(args, cb) { args = [args]; } - childProcess.execFile('../cli.js', args, {cwd: __dirname}, cb); + childProcess.execFile(process.execPath, ['../cli.js'].concat(args), {cwd: __dirname}, cb); } test('run test', function (t) {