Browse Source

wait for fork to exit and then return results

babel-plugin-for-integration-tests
vdemedes 9 years ago
parent
commit
1d01665f70
  1. 6
      lib/fork.js
  2. 8
      test/fixture/process-cwd.js
  3. 6
      test/test.js

6
lib/fork.js

@ -19,8 +19,10 @@ module.exports = function (args) {
var ps = childProcess.fork(babel, args, options);
var promise = new Promise(function (resolve, reject) {
var testResults;
ps.on('results', function (results) {
resolve(results);
testResults = results;
// after all tests are finished and results received
// kill the forked process, so AVA can exit safely
@ -32,6 +34,8 @@ module.exports = function (args) {
ps.on('exit', function (code) {
if (code > 0) {
reject();
} else {
resolve(testResults);
}
});
});

8
test/fixture/process-cwd.js

@ -1 +1,7 @@
console.log(process.cwd());
'use strict';
const test = require('../../');
test(t => {
t.is(process.cwd(), __dirname);
t.end();
});

6
test/test.js

@ -3,7 +3,6 @@ var childProcess = require('child_process');
var Promise = require('bluebird');
var figures = require('figures');
var test = require('tape');
var path = require('path');
var Runner = require('../lib/runner');
var ava = require('../lib/test');
@ -945,11 +944,10 @@ test('power-assert support', function (t) {
});
test('change process.cwd() to a test\'s directory', function (t) {
t.plan(2);
t.plan(1);
execCli('fixture/process-cwd.js', function (err, stdout) {
execCli('fixture/process-cwd.js', function (err) {
t.ifError(err);
t.is(stdout.trim(), path.join(__dirname, 'fixture'));
t.end();
});
});

Loading…
Cancel
Save