diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/config.py | 8 | ||||
-rw-r--r-- | coverage/control.py | 11 | ||||
-rw-r--r-- | coverage/data.py | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/coverage/config.py b/coverage/config.py index 6b441ddc..e72a728b 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -55,6 +55,9 @@ class CoverageConfig(object): # Defaults for [xml] self.xml_output = "coverage.xml" + # Defaults for [paths] + self.paths = {} + def from_environment(self, env_var): """Read configuration from the `env_var` environment variable.""" # Timidity: for nose users, read an environment variable. This is a @@ -124,6 +127,11 @@ class CoverageConfig(object): if cp.has_option('xml', 'output'): self.xml_output = cp.get('xml', 'output') + # [paths] + if cp.has_section('paths'): + for option in cp.options('paths'): + self.paths[option] = self.get_list(cp, 'paths', option) + def get_list(self, cp, section, option): """Read a list of strings from the ConfigParser `cp`. diff --git a/coverage/control.py b/coverage/control.py index 4ba3a034..a77d805d 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -9,7 +9,7 @@ from coverage.collector import Collector from coverage.config import CoverageConfig from coverage.data import CoverageData from coverage.files import FileLocator, TreeMatcher, FnmatchMatcher -from coverage.files import find_python_files +from coverage.files import PathAliases, find_python_files from coverage.html import HtmlReporter from coverage.misc import CoverageException, bool_or_none, join_regex from coverage.results import Analysis, Numbers @@ -467,7 +467,14 @@ class coverage(object): current measurements. """ - self.data.combine_parallel_data() + aliases = None + if self.config.paths: + aliases = PathAliases() + for paths in self.config.paths.values(): + result = paths[0] + for pattern in paths[1:]: + aliases.add(pattern, result) + self.data.combine_parallel_data(aliases=aliases) def _harvest_data(self): """Get the collected data and reset the collector. diff --git a/coverage/data.py b/coverage/data.py index 1d6799f0..7a8d656f 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -176,7 +176,7 @@ class CoverageData(object): Treat `self.filename` as a file prefix, and combine the data from all of the data files starting with that prefix plus a dot. - If `aliases` is provided, it's a PathAliases object that is used to + If `aliases` is provided, it's a `PathAliases` object that is used to re-map paths to match the local machine's. """ |