Travis: report coverage with all builds#2800
Conversation
|
It seems to be problematic with py27/py26 (https://travis-ci.org/pytest-dev/pytest/builds/280216101). Is this something we want to have in general? |
nicoddemus
left a comment
There was a problem hiding this comment.
I'm in favor of improving our coverage testing. 👍
Your approach also seems to be possible to implement on AppVeyor.
Ultimately we should strive to obtain 100% coverage, even if by explicitly marking parts of the code which are not currently tested (like java specific parts). Even if we "cheat", we gain the benefit of demanding that new code from now on has 100% coverage.
.travis.yml
Outdated
| install: | ||
| - pip install --upgrade --pre tox | ||
| - | | ||
| pip install tox |
There was a problem hiding this comment.
tox is already installed in the line above, so this is not really needed
.travis.yml
Outdated
| - pip install --upgrade --pre tox | ||
| - | | ||
| pip install tox | ||
| if [[ "${TOXENV#py}" != "$TOXENV" ]]; then |
There was a problem hiding this comment.
Pardon my lack of bash-fu, what does this expression inside if does?
There was a problem hiding this comment.
TOXENV starts with "py".
There was a problem hiding this comment.
Thanks, and what does "${TOXENV#py}" do? (I tried googling it but it wasn't entirely obvious what to search for).
There was a problem hiding this comment.
It substitutes "py" at the beginning.
Yes, shell programming can be ugly. See "Parameter Expansion" in bash's man page.
tox.ini
Outdated
| {env:TOX_EXTRA_DEPS:} | ||
| commands = | ||
| pytest -ra test_pdb.py test_terminal.py test_unittest.py | ||
| {env:TOX_COVERAGE_RUN:} pytest -ra test_pdb.py test_terminal.py test_unittest.py |
There was a problem hiding this comment.
Looking at the Travis build, py27/py36-trial seem to be missing this configuration
.coveragerc
Outdated
| [run] | ||
| source = _pytest | ||
| omit = | ||
| # standlonetemplate is read dynamically and tested by test_genscript |
There was a problem hiding this comment.
Oh this does not exist anymore and can be removed. 😁
There was a problem hiding this comment.
standlonetemplate? Fixed (not pushed).
Apart from that I think we should also include testing (the tests themselves). Anything else?
There was a problem hiding this comment.
"standlonetemplate" was used by the removed genscript feature.
Apart from that I think we should also include testing (the tests themselves). Anything else?
Not sure, then xfail tests which are never meant to run because they reproduce issues not yet fixed will drop the coverage. In my head "coverage" does not include the tests. What's your opinion?
There was a problem hiding this comment.
I think unexpected missing coverage is a good sign of something being wrong.
Those xfail tests should be marked with "pragma: no cover" then.
.travis.yml
Outdated
| - | | ||
| pip install tox | ||
| if [[ "${TOXENV#py}" != "$TOXENV" ]]; then | ||
| export TOX_COVERAGE_RUN="coverage run -m" |
There was a problem hiding this comment.
At first glance I thought TOX_EXTRA_DEPS was a feature of tox itself. Perhaps we should add a PYTEST_ prefix to avoid confusion? While at it, perhaps there is a way to add extra dependencies using some tox feature?
There was a problem hiding this comment.
Just remembered that we used _PYTEST_SETUP_SKIP_PLUGGY_DEP in setup.py for this type of "setup/buid only flag used internally".
_PYTEST_TOX_COVERAGE_RUN?
There was a problem hiding this comment.
Makes sense. Will rename it to _PYTEST_TOX_COVERAGE_RUN and _PYTEST_TOX_EXTRA_DEPS then?
|
Failures on py2, pypy and py33 are all: e.g. https://travis-ci.org/pytest-dev/pytest/jobs/280479131#L599 Any idea? (likely related to the assertions there not being true when run on coverage likely?!) |
|
@nicoddemus |
Done! If we will use |
|
The problem with
|
|
This works around it: diff --git i/testing/code/test_excinfo.py w/testing/code/test_excinfo.py
index f8f8a036..cc512a2d 100644
--- i/testing/code/test_excinfo.py
+++ w/testing/code/test_excinfo.py
@@ -162,9 +162,12 @@ def test_traceback_cut(self):
assert len(newtraceback) == 1
def test_traceback_cut_excludepath(self, testdir):
+ ptf = py.path.local(pytest.__file__)
+ if not ptf.exists():
+ pytest.skip('pytest.__file__ does not point to an actual file.')
+ basedir = ptf.dirpath()
p = testdir.makepyfile("def f(): raise ValueError")
excinfo = pytest.raises(ValueError, "p.pyimport().f()")
- basedir = py.path.local(pytest.__file__).dirpath()
newtraceback = excinfo.traceback.cut(excludepath=basedir)
for x in newtraceback:
if hasattr(x, 'path'):Looks like an issue with Python 2 where |
|
I gotta say I like codecov's report better. 😄 |
nicoddemus
left a comment
There was a problem hiding this comment.
There's some environments failing, could you take a look at those?
.travis.yml
Outdated
| pip install codecov coveralls | ||
| coverage xml | ||
| coverage report -m | ||
| coveralls |
There was a problem hiding this comment.
Should we drop coveralls if we are migrating to codecov?
There was a problem hiding this comment.
I think it is good to keep it for comparison, at least for a while.
tox.ini
Outdated
| {env:TOX_EXTRA_DEPS:} | ||
| commands = | ||
| pytest -n3 -ra --runpytest=subprocess {posargs:testing} | ||
| {env:TOX_COVERAGE_RUN:} pytest -n3 -ra --runpytest=subprocess {posargs:testing} |
There was a problem hiding this comment.
I'm seeing this warning from tox:
WARNING:test command found but not installed in testenv
cmd: /usr/bin/env
env: /home/travis/build/pytest-dev/pytest/.tox/py27
Do we have to whitelist env?
There was a problem hiding this comment.
pytest-cov does incomplete reports due to late plugin startup, its a longstanding pytest issue
tox.ini
Outdated
| coverage run --source=_pytest -m pytest testing | ||
| coverage report -m | ||
| coveralls | ||
| {env:TOX_COVERAGE_RUN:} {envpython} create_executable.py |
There was a problem hiding this comment.
We can drop coverage from this env I believe
tox.ini
Outdated
|
|
||
| [testenv] | ||
| commands = pytest --lsof -ra {posargs:testing} | ||
| commands = {env:TOX_COVERAGE_RUN:} pytest --lsof -ra {posargs:testing} |
There was a problem hiding this comment.
can we just introduce a coverage factor for this?
There was a problem hiding this comment.
@RonnyPfannschmidt
There is no way to have a command by default and then another for a factor, is there? (where the command comes not from the default testenv).
There was a problem hiding this comment.
Will do it via setenv:
[testenv]
commands = {env:_TOX_COVERAGE_RUN:} pytest --lsof -ra {posargs:testing}
coverage: coverage report -m --skip-covered
setenv =
coverage: _TOX_COVERAGE_RUN=env COVERAGE_FILE={toxinidir}/.coverage coverage run -a -m
whitelist_externals =
coverage: env
.travis.yml
Outdated
| - pip install --upgrade --pre tox | ||
| - | | ||
| if [[ "${TOXENV#py}" != "$TOXENV" ]]; then | ||
| export TOX_COVERAGE_RUN="env COVERAGE_FILE=$PWD/.coverage coverage run -a -m" |
There was a problem hiding this comment.
at frist glance this "breaks" at least for the xdist envs
tox.ini
Outdated
| nose | ||
| mock | ||
| requests | ||
| {env:TOX_EXTRA_DEPS:} |
|
instead of falling out for pytest in some cases lets use |
You mean in the production code or the test? |
|
in |
| coverage report -m | ||
| codecov --required -X gcov pycov search -f coverage.xml --flags ${TOXENV//-/ } | ||
|
|
||
| # Coveralls does not support merged reports. |
There was a problem hiding this comment.
I believe we can drop coveralls then. Or would you rather do it in another PR @blueyed?
There was a problem hiding this comment.
I've thought to keep it for comparison.
There was a problem hiding this comment.
Oh OK. But I think we should remove it after a while to avoid confusion. 👍
| @@ -1,53 +0,0 @@ | |||
| environment: | |||
There was a problem hiding this comment.
I assume you removed AppVeyor so the builds are faster, please remember to bring it back before merging.
tox.ini
Outdated
| {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --lsof -ra {env:_PYTEST_TEST_OPTS:} {posargs:testing} | ||
| coverage: coverage report -m --skip-covered | ||
| setenv = | ||
| coverage: _PYTEST_TOX_COVERAGE_RUN=coverage run -a -m |
There was a problem hiding this comment.
Why do we handle _PYTEST_TOX_COVERAGE_RUN and _PYTEST_TOX_EXTRA_DEP both here and in the travis file?
There was a problem hiding this comment.
This is meant to allow for tox -e py36-coverage.
I've thought about/tried using only -coverage, but it is not trivial/feasible due to the many different testenvs.
|
Squashed (old HEAD: 78d2c4d). |
|
Meh.. AppVeyor will fail - still using TOXENV=coveralls.. I guess the same mechanism should be used with AppVeyor then? Basically the |
|
@blueyed sure I can give it a try. For now I suggest to comment out the |
Codecov Report
@@ Coverage Diff @@
## master #2800 +/- ##
==========================================
+ Coverage 92.18% 96.24% +4.05%
==========================================
Files 52 108 +56
Lines 10009 23353 +13344
==========================================
+ Hits 9227 22475 +13248
- Misses 782 878 +96
Continue to review full report at Codecov.
|
|
Rebased it on master (where the other ci improvements are already), and re-added coveralls for AppVeyor. Since it also runs codecov there it should be good for Windows for now. |
You mean |
|
Both, since 4d19b94. |
|
Fixed linting, squashed the keeping of coveralls for AppVeyor: diff --git a/.travis.yml b/.travis.yml
index 9279334e..2c9deb3e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -60,7 +60,7 @@ jobs:
env: TOXENV=py27
- env: TOXENV=py34
- env: TOXENV=py36
- - env: TOXENV=linting
+ - env: TOXENV=linting PYTEST_NO_COVERAGE=1
- stage: deploy
python: '3.6' |
This comment has been minimized.
This comment has been minimized.
- Skips pypy for coverage, reports only py37 to coveralls - tox: allow for TOXENV=py37-coverage - tracks coverage in subprocesses, using coverage-enable-subprocess, and parallel=1 - removes usedevelop with doctesting to match `--source` being used with coverage - keep coveralls for now, used with AppVeyor
9d883e1 to
794fd05
Compare
doctesting: remove changedir With coverage 5 we could use COVERAGE_RCFILE to make it find the .coveragerc, or we could add `--rcfile` to _PYTEST_TOX_COVERAGE_RUN, but I've thought that this should not be the job that has to test if `--pyargs` actually works.
|
doctesting is working now (https://travis-ci.org/pytest-dev/pytest/jobs/422263747#L677), but I've changed the tox testenv quite a bit. |
|
Thanks a ton @blueyed! |
|
Yay! :) |
https://codecov.io/gh/pytest-dev/pytest/tree/coverage
TODO: