|
|
@ -19,6 +19,8 @@ module.exports = function (file, opts) { |
|
|
|
|
|
|
|
var ps = childProcess.fork(filepath, args, options); |
|
|
|
|
|
|
|
var relFile = path.relative('.', file); |
|
|
|
|
|
|
|
var promise = new Promise(function (resolve, reject) { |
|
|
|
var testResults; |
|
|
|
|
|
|
@ -31,19 +33,19 @@ module.exports = function (file, opts) { |
|
|
|
|
|
|
|
ps.on('exit', function (code) { |
|
|
|
if (code > 0 && code !== 143) { |
|
|
|
return reject(new Error(file + ' exited with a non-zero exit code: ' + code)); |
|
|
|
return reject(new Error(relFile + ' exited with a non-zero exit code: ' + code)); |
|
|
|
} |
|
|
|
|
|
|
|
if (testResults) { |
|
|
|
resolve(testResults); |
|
|
|
} else { |
|
|
|
reject(new Error('Test results were not received from: ' + file)); |
|
|
|
reject(new Error('Test results were not received from ' + relFile)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
ps.on('no-tests', function (data) { |
|
|
|
send(ps, 'teardown'); |
|
|
|
var message = 'No tests found in ' + path.relative('.', file); |
|
|
|
var message = 'No tests found in ' + relFile; |
|
|
|
if (!data.avaRequired) { |
|
|
|
message += ', make sure to import "ava" at the top of your test file'; |
|
|
|
} |
|
|
@ -58,7 +60,7 @@ module.exports = function (file, opts) { |
|
|
|
} |
|
|
|
|
|
|
|
event.name = event.name.replace(/^ava\-/, ''); |
|
|
|
event.data.file = file; |
|
|
|
event.data.file = relFile; |
|
|
|
|
|
|
|
debug('ipc %s:\n%o', event.name, event.data); |
|
|
|
ps.emit(event.name, event.data); |
|
|
|