diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..4028f8ea0 --- /dev/null +++ b/.coveragerc @@ -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 diff --git a/.gitignore b/.gitignore index 2e606cc2d..e7c1d5f43 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ zope.interface-*.egg /violations.txt /.tox/ /docs/_build/ +/coverage.xml diff --git a/src/allmydata/test/run_trial.py b/src/allmydata/test/run_trial.py new file mode 100644 index 000000000..29be3262e --- /dev/null +++ b/src/allmydata/test/run_trial.py @@ -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() diff --git a/tox.ini b/tox.ini index 9b96a4320..5137a3082 100644 --- a/tox.ini +++ b/tox.ini @@ -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