tox: add "coverage" environment

Run with "tox -e coverage". Uses a new helper
module (allmydata.test.run_trial) to let us import+execute trial without
knowing exactly where the "trial" binary lives, which helps with using
"coverage run" under tox.
This commit is contained in:
Brian Warner 2016-05-09 13:59:54 -07:00
parent 1e1e86fe35
commit 608719df91
4 changed files with 36 additions and 0 deletions

10
.coveragerc Normal file
View File

@ -0,0 +1,10 @@
# -*- mode: conf -*-
[run]
# only record trace data for allmydata.*
source =
allmydata
# and don't trace the test files themselves, or generated files
omit =
*/allmydata/test/*
*/allmydata/_version.py

1
.gitignore vendored
View File

@ -37,3 +37,4 @@ zope.interface-*.egg
/violations.txt
/.tox/
/docs/_build/
/coverage.xml

View File

@ -0,0 +1,16 @@
# This is a tiny helper module, to let "python -m allmydata.test.run_trial
# ARGS" does the same thing as running "trial ARGS" (unfortunately
# twisted/scripts/trial.py does not have a '__name__=="__main__"' clause).
#
# This makes it easier to run trial under coverage from tox:
# * "coverage run trial ARGS" is how you'd usually do it
# * but "trial" must be the one in tox's virtualenv
# * "coverage run `which trial` ARGS" works from a shell
# * but tox doesn't use a shell
# So use:
# "coverage run -m allmydata.test.run_trial ARGS"
from twisted.scripts.trial import run
run()

View File

@ -15,6 +15,15 @@ commands =
tahoe --version
trial --rterrors {posargs:allmydata}
[testenv:coverage]
# coverage (with --branch) takes about 65% longer to run
passenv = USERPROFILE HOMEDRIVE HOMEPATH
skip_install = True
deps = --editable=.[test]
commands =
tahoe --version
coverage run --branch -m allmydata.test.run_trial --rterrors --reporter=timing {posargs:allmydata}
[testenv:deprecations]
basepython=python2.7
passenv = USERPROFILE HOMEDRIVE HOMEPATH