diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-03-28 06:21:34 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-03-28 06:21:34 -0400 |
commit | c2636f945f5c46597f71479ac8eae3a141110cf5 (patch) | |
tree | 5c048b46eb7917f004dcf507550b3b989761f5e4 /coverage/control.py | |
parent | 507d94b272fb73fac476fa6cdc6b023f5c88bc79 (diff) | |
download | python-coveragepy-git-c2636f945f5c46597f71479ac8eae3a141110cf5.tar.gz |
Allow plugins to report files they haven't executed.
By Emil Madsen, from: https://github.com/nedbat/coveragepy/pull/28
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/coverage/control.py b/coverage/control.py index 30923b9d..1f79e2f0 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -3,8 +3,10 @@ """Core control stuff for coverage.py.""" + import atexit import inspect +import itertools import os import platform import re @@ -854,6 +856,11 @@ class Coverage(object): if self.config.note: self.data.add_run_info(note=self.config.note) + def _find_plugin_files(self, src_dir): + for plugin in self.plugins: + for x_file in plugin.find_executable_files(src_dir): + yield x_file, plugin._coverage_plugin_name + def _find_unexecuted_files(self, src_dir): """Find unexecuted files in `src_dir`. @@ -861,15 +868,16 @@ class Coverage(object): and add them as unexecuted files in `self.data`. """ - for py_file in find_python_files(src_dir): - py_file = files.canonical_filename(py_file) + py_files = ((py_file, None) for py_file in files.find_python_files(src_dir)) + plugin_files = self._find_plugin_files(src_dir) - if self.omit_match and self.omit_match.match(py_file): + for file_path, plugin_name in itertools.chain(py_files, plugin_files): + file_path = files.canonical_filename(file_path) + if self.omit_match and self.omit_match.match(file_path): # Turns out this file was omitted, so don't pull it back # in as unexecuted. continue - - self.data.touch_file(py_file) + self.data.touch_file(file_path, plugin_name) # Backward compatibility with version 1. def analysis(self, morf): |