From 0a40bdb11967a72d543ab11447d7f430f34acc92 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 25 Dec 2015 18:59:49 +0100 Subject: [PATCH] use relative file paths on the fork.js output --- lib/fork.js | 10 ++++++---- test/fork.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/fork.js b/lib/fork.js index d0f6644..12ee753 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -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); diff --git a/test/fork.js b/test/fork.js index d1d10c7..788f5db 100644 --- a/test/fork.js +++ b/test/fork.js @@ -28,7 +28,7 @@ test('resolves promise with tests info', function (t) { .then(function (info) { t.is(info.stats.passCount, 1); t.is(info.tests.length, 1); - t.is(info.file, file); + t.is(info.file, path.relative('.', file)); t.end(); }); });