Skip to content

Commit

Permalink
Track coverage in subprocesses
Browse files Browse the repository at this point in the history
This currently only works for ./zdaemon executed from the README.rst
test.  Other tests need to be modified in a similar way (i.e. call
coverage.process_start() in the child process, if 'coverage' is
importable).

Warning: if you intend to run 'coverage report' or 'coverage xml', you
need to explicitly set COVERAGE_HOME=. or it will fail to find the
covergae information.
  • Loading branch information
mgedmin committed Apr 15, 2015
1 parent 81b540d commit d832b17
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[run]
source = zdaemon
source = $COVERAGE_HOME/src/zdaemon
omit = */tests/*, */__main__.py
parallel = true
data_file = $COVERAGE_HOME/.coverage

[report]
exclude_lines =
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ develop-eggs/
eggs/
parts/
.coverage
.coverage.*
7 changes: 7 additions & 0 deletions src/zdaemon/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ def checkenv(match):
%(ZConfig)r,
]
try:
import coverage
except ImportError:
pass
else:
coverage.process_startup()
import zdaemon.zdctl
if __name__ == '__main__':
Expand Down
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ deps =
usedevelop = true
basepython =
python2.7
setenv =
COVERAGE_HOME={toxinidir}
COVERAGE_PROCESS_START={toxinidir}/.coveragerc
commands =
coverage run --source=zdaemon setup.py -q test
coverage combine
coverage report
deps =
{[testenv]deps}
Expand Down

0 comments on commit d832b17

Please sign in to comment.