aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/test-worker.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/ava/lib/test-worker.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/ava/lib/test-worker.js')
-rw-r--r--node_modules/ava/lib/test-worker.js36
1 files changed, 26 insertions, 10 deletions
diff --git a/node_modules/ava/lib/test-worker.js b/node_modules/ava/lib/test-worker.js
index 2df7f745d..0061775f0 100644
--- a/node_modules/ava/lib/test-worker.js
+++ b/node_modules/ava/lib/test-worker.js
@@ -17,18 +17,18 @@
}
}
-/* eslint-enable import/order */
-const Bluebird = require('bluebird');
-const currentlyUnhandled = require('currently-unhandled')();
-const isObj = require('is-obj');
const adapter = require('./process-adapter');
const globals = require('./globals');
-const serializeError = require('./serialize-error');
const opts = adapter.opts;
-const testPath = opts.file;
globals.options = opts;
+/* eslint-enable import/order */
+const Bluebird = require('bluebird');
+const currentlyUnhandled = require('currently-unhandled')();
+const isObj = require('is-obj');
+const serializeError = require('./serialize-error');
+
// Bluebird specific
Bluebird.longStackTraces();
@@ -37,16 +37,28 @@ Bluebird.longStackTraces();
adapter.installSourceMapSupport();
adapter.installPrecompilerHook();
-const dependencies = [];
+const testPath = opts.file;
+
+const dependencies = new Set();
adapter.installDependencyTracking(dependencies, testPath);
+const touchedFiles = new Set();
+
// Set when main.js is required (since test files should have `require('ava')`).
let runner = null;
exports.setRunner = newRunner => {
runner = newRunner;
+ runner.on('dependency', file => {
+ dependencies.add(file);
+ });
+ runner.on('touched', files => {
+ for (const file of files) {
+ touchedFiles.add(file);
+ }
+ });
};
-require(testPath); // eslint-disable-line import/no-dynamic-require
+require(testPath);
// If AVA was not required, show an error
if (!runner) {
@@ -121,8 +133,12 @@ process.on('ava-teardown', () => {
// Include dependencies in the final teardown message. This ensures the full
// set of dependencies is included no matter how the process exits, unless
- // it flat out crashes.
- adapter.send('teardown', {dependencies});
+ // it flat out crashes. Also include any files that AVA touched during the
+ // test run. This allows the watcher to ignore modifications to those files.
+ adapter.send('teardown', {
+ dependencies: Array.from(dependencies),
+ touchedFiles: Array.from(touchedFiles)
+ });
});
process.on('ava-exit', () => {