diff options
Diffstat (limited to 'node_modules/ava/lib/watcher.js')
-rw-r--r-- | node_modules/ava/lib/watcher.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/node_modules/ava/lib/watcher.js b/node_modules/ava/lib/watcher.js index c90c810f0..3f5ed3ee7 100644 --- a/node_modules/ava/lib/watcher.js +++ b/node_modules/ava/lib/watcher.js @@ -25,6 +25,7 @@ class Debouncer { this.timer = null; this.repeat = false; } + debounce(delay) { if (this.timer) { this.again = true; @@ -55,6 +56,7 @@ class Debouncer { this.timer = timer; } + cancel() { if (this.timer) { clearTimeout(this.timer); @@ -69,6 +71,7 @@ class TestDependency { this.file = file; this.sources = sources; } + contains(source) { return this.sources.indexOf(source) !== -1; } @@ -146,6 +149,7 @@ class Watcher { this.watchFiles(); this.rerunAll(); } + watchFiles() { const patterns = this.avaFiles.getChokidarPatterns(); @@ -160,16 +164,18 @@ class Watcher { } }); } + trackTestDependencies(api) { const relative = absPath => nodePath.relative(process.cwd(), absPath); api.on('test-run', runStatus => { runStatus.on('dependencies', (file, dependencies) => { - const sourceDeps = dependencies.map(relative).filter(this.avaFiles.isSource); + const sourceDeps = dependencies.map(x => relative(x)).filter(this.avaFiles.isSource); this.updateTestDependencies(file, sourceDeps); }); }); } + updateTestDependencies(file, sources) { if (sources.length === 0) { this.testDependencies = this.testDependencies.filter(dep => dep.file !== file); @@ -190,6 +196,7 @@ class Watcher { this.testDependencies.push(new TestDependency(file, sources)); } } + trackTouchedFiles(api) { api.on('test-run', runStatus => { runStatus.on('touchedFiles', files => { @@ -199,11 +206,13 @@ class Watcher { }); }); } + trackExclusivity(api) { api.on('stats', stats => { this.updateExclusivity(stats.file, stats.hasExclusive); }); } + updateExclusivity(file, hasExclusiveTests) { const index = this.filesWithExclusiveTests.indexOf(file); @@ -213,6 +222,7 @@ class Watcher { this.filesWithExclusiveTests.splice(index, 1); } } + trackFailures(api) { api.on('test-run', (runStatus, files) => { files.forEach(file => { @@ -230,9 +240,11 @@ class Watcher { }); }); } + pruneFailures(file) { this.filesWithFailures = this.filesWithFailures.filter(state => state.file !== file); } + countFailure(file, vector) { const isUpdate = this.filesWithFailures.some(state => { if (state.file !== file) { @@ -251,6 +263,7 @@ class Watcher { }); } } + sumPreviousFailures(beforeVector) { let total = 0; @@ -262,6 +275,7 @@ class Watcher { return total; } + cleanUnlinkedTests(unlinkedTests) { unlinkedTests.forEach(testFile => { this.updateTestDependencies(testFile, []); @@ -269,6 +283,7 @@ class Watcher { this.pruneFailures(testFile); }); } + observeStdin(stdin) { stdin.resume(); stdin.setEncoding('utf8'); @@ -295,14 +310,17 @@ class Watcher { }); }); } + rerunAll() { this.dirtyStates = {}; this.run(); } + updatePreviousSnapshots() { this.dirtyStates = {}; this.run(this.previousFiles, true); } + runAfterChanges() { const dirtyStates = this.dirtyStates; this.dirtyStates = {}; |