test: Add conditional coverage measurement

This commit is contained in:
Tomas Babej 2015-03-27 16:29:51 +01:00
parent 3aaafaa418
commit 26f23ce5f9
2 changed files with 17 additions and 1 deletions

View file

@ -3,6 +3,21 @@ import itertools
import sys
import vim # pylint: disable=F0401
# Start measuring coverage if in testing
if vim.vars.get('taskwiki_measure_coverage'):
import os
import atexit
import coverage
coverage_path = os.path.expanduser('~/taskwiki-coverage/.coverage.{0}'.format(os.getpid()))
cov = coverage.coverage(data_file=coverage_path)
cov.start()
def save_coverage():
cov.stop()
cov.save()
atexit.register(save_coverage)
from tasklib.task import TaskWarrior, Task
# Insert the taskwiki on the python path

View file

@ -39,9 +39,10 @@ class IntegrationTest(object):
def setup(self):
self.generate_data()
self.client = server.start_gvim()
self.command('let g:taskwiki_measure_coverage="yes"')
self.command('let g:taskwiki_data_location="{0}"'.format(self.dir))
self.add_plugin('taskwiki')
self.add_plugin('vimwiki')
self.command('let g:taskwiki_data_location="{0}"'.format(self.dir))
self.client.edit(os.path.join(self.dir, 'testwiki.txt'))
self.command('set filetype=vimwiki', silent=False) # TODO: fix these vimwiki loading errors