summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'coverage')
-rw-r--r--coverage/collector.py11
-rw-r--r--coverage/control.py15
2 files changed, 19 insertions, 7 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index 64abed4..1c8c83b 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -348,7 +348,7 @@ class Collector(object):
else:
self._start_tracer()
- def activity(self):
+ def _activity(self):
"""Has any activity been traced?
Returns a boolean, True if any trace function was invoked.
@@ -365,7 +365,13 @@ class Collector(object):
tracer.data = data
def save_data(self, covdata):
- """Save the collected data to a `CoverageData`."""
+ """Save the collected data to a `CoverageData`.
+
+ Returns True if there was data to save, False if not.
+ """
+ if not self._activity():
+ return False
+
def abs_file_dict(d):
"""Return a dict like d, but with keys modified by `abs_file`."""
return dict((abs_file(k), v) for k, v in iitems(d))
@@ -384,3 +390,4 @@ class Collector(object):
pprint.pprint(self.contexts, wtw_out)
self._clear_data()
+ return True
diff --git a/coverage/control.py b/coverage/control.py
index a12eb2e..40c2266 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -797,11 +797,18 @@ class Coverage(object):
"""
self._init()
- if not self.collector.activity():
- return self.data
+ if self.collector.save_data(self.data):
+ self._post_save_work()
- self.collector.save_data(self.data)
+ return self.data
+
+ def _post_save_work(self):
+ """After saving data, look for warnings, post-work, etc.
+
+ Warn about things that should have happened but didn't.
+ Look for unexecuted files.
+ """
# If there are still entries in the source_pkgs_unmatched list,
# then we never encountered those packages.
if self._warn_unimported_source:
@@ -835,8 +842,6 @@ class Coverage(object):
if self.config.note:
self.data.add_run_info(note=self.config.note)
- return self.data
-
def _find_unexecuted_files(self, src_dir):
"""Find unexecuted files in `src_dir`.