Travis: report coverage with all builds

- 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
This commit is contained in:
Daniel Hahler 2017-09-27 00:46:50 +02:00
parent d76fb8345c
commit f730291e67
3 changed files with 66 additions and 24 deletions

View File

@ -1,4 +1,3 @@
[run] [run]
omit = source = _pytest,testing
# standlonetemplate is read dynamically and tested by test_genscript parallel = 1
*standalonetemplate.py

View File

@ -11,8 +11,6 @@ install:
- pip install --upgrade --pre tox - pip install --upgrade --pre tox
env: env:
matrix: matrix:
# coveralls is not listed in tox's envlist, but should run in travis
- TOXENV=coveralls
# note: please use "tox --listenvs" to populate the build matrix below # note: please use "tox --listenvs" to populate the build matrix below
# please remove the linting env in all cases # please remove the linting env in all cases
- TOXENV=py27-pexpect - TOXENV=py27-pexpect
@ -27,15 +25,16 @@ env:
- TOXENV=py36-pluggymaster - TOXENV=py36-pluggymaster
- TOXENV=py27-nobyte - TOXENV=py27-nobyte
- TOXENV=doctesting - TOXENV=doctesting
- TOXENV=docs - TOXENV=docs PYTEST_NO_COVERAGE=1
jobs: jobs:
include: include:
- env: TOXENV=pypy # Coverage tracking is slow with pypy, skip it.
- env: TOXENV=pypy PYTEST_NO_COVERAGE=1
python: 'pypy-5.4' python: 'pypy-5.4'
- env: TOXENV=py35 - env: TOXENV=py35
python: '3.5' python: '3.5'
- env: TOXENV=py36-freeze - env: TOXENV=py36-freeze PYTEST_NO_COVERAGE=1
python: '3.6' python: '3.6'
- env: TOXENV=py37 - env: TOXENV=py37
python: '3.7' python: '3.7'
@ -61,7 +60,7 @@ jobs:
env: TOXENV=py27 env: TOXENV=py27
- env: TOXENV=py34 - env: TOXENV=py34
- env: TOXENV=py36 - env: TOXENV=py36
- env: TOXENV=linting - env: TOXENV=linting PYTEST_NO_COVERAGE=1
- stage: deploy - stage: deploy
python: '3.6' python: '3.6'
@ -79,8 +78,33 @@ jobs:
tags: true tags: true
repo: pytest-dev/pytest repo: pytest-dev/pytest
before_script:
- |
if [[ "$PYTEST_NO_COVERAGE" != 1 ]]; then
export _PYTEST_TOX_COVERAGE_RUN="env COVERAGE_FILE=$PWD/.coverage coverage run --source {envsitepackagesdir}/_pytest/,$PWD/testing -m"
export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess
export COVERAGE_PROCESS_START="$PWD/.coveragerc"
fi
script: tox --recreate script: tox --recreate
after_success:
- |
if [[ "$PYTEST_NO_COVERAGE" != 1 ]]; then
set -e
pip install codecov
coverage combine
coverage xml
coverage report -m
codecov --required -X gcov pycov search -f coverage.xml --flags ${TOXENV//-/ }
# Coveralls does not support merged reports.
if [[ "$TOXENV" = py37 ]]; then
pip install coveralls
coveralls
fi
fi
notifications: notifications:
irc: irc:
channels: channels:

49
tox.ini
View File

@ -17,13 +17,21 @@ envlist =
docs docs
[testenv] [testenv]
commands = pytest --lsof -ra {posargs:testing} commands =
passenv = USER USERNAME {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
coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocesses
coverage: COVERAGE_FILE={toxinidir}/.coverage
coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc
passenv = USER USERNAME COVERAGE_PROCESS_START
deps = deps =
hypothesis>=3.56 hypothesis>=3.56
nose nose
mock mock
requests requests
{env:_PYTEST_TOX_EXTRA_DEP:}
[testenv:py27-subprocess] [testenv:py27-subprocess]
changedir = . changedir = .
@ -47,9 +55,10 @@ deps =
mock mock
nose nose
hypothesis>=3.56 hypothesis>=3.56
{env:_PYTEST_TOX_EXTRA_DEP:}
changedir=testing changedir=testing
commands = commands =
pytest -n8 -ra {posargs:.} {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n8 -ra {posargs:.}
[testenv:py36-xdist] [testenv:py36-xdist]
deps = {[testenv:py27-xdist]deps} deps = {[testenv:py27-xdist]deps}
@ -58,9 +67,11 @@ commands = {[testenv:py27-xdist]commands}
[testenv:py27-pexpect] [testenv:py27-pexpect]
changedir = testing changedir = testing
platform = linux|darwin platform = linux|darwin
deps = pexpect deps =
pexpect
{env:_PYTEST_TOX_EXTRA_DEP:}
commands = commands =
pytest -ra test_pdb.py test_terminal.py test_unittest.py {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra test_pdb.py test_terminal.py test_unittest.py
[testenv:py36-pexpect] [testenv:py36-pexpect]
changedir = {[testenv:py27-pexpect]changedir} changedir = {[testenv:py27-pexpect]changedir}
@ -73,26 +84,32 @@ deps =
pytest-xdist>=1.13 pytest-xdist>=1.13
hypothesis>=3.56 hypothesis>=3.56
mock mock
{env:_PYTEST_TOX_EXTRA_DEP:}
distribute = true distribute = true
changedir=testing changedir=testing
setenv = setenv =
{[testenv]setenv}
PYTHONDONTWRITEBYTECODE=1 PYTHONDONTWRITEBYTECODE=1
commands = commands =
pytest -n3 -ra {posargs:.} {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n3 -ra {posargs:.}
[testenv:py27-trial] [testenv:py27-trial]
deps = twisted deps =
twisted
{env:_PYTEST_TOX_EXTRA_DEP:}
commands = commands =
pytest -ra {posargs:testing/test_unittest.py} {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra {posargs:testing/test_unittest.py}
[testenv:py36-trial] [testenv:py36-trial]
deps = {[testenv:py27-trial]deps} deps = {[testenv:py27-trial]deps}
commands = {[testenv:py27-trial]commands} commands = {[testenv:py27-trial]commands}
[testenv:py27-numpy] [testenv:py27-numpy]
deps = numpy deps =
numpy
{env:_PYTEST_TOX_EXTRA_DEP:}
commands= commands=
pytest -ra {posargs:testing/python/approx.py} {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra {posargs:testing/python/approx.py}
[testenv:py36-numpy] [testenv:py36-numpy]
deps = {[testenv:py27-numpy]deps} deps = {[testenv:py27-numpy]deps}
@ -100,6 +117,7 @@ commands = {[testenv:py27-numpy]commands}
[testenv:py27-pluggymaster] [testenv:py27-pluggymaster]
setenv= setenv=
{[testenv]setenv}
_PYTEST_SETUP_SKIP_PLUGGY_DEP=1 _PYTEST_SETUP_SKIP_PLUGGY_DEP=1
deps = deps =
{[testenv]deps} {[testenv]deps}
@ -123,15 +141,15 @@ commands =
[testenv:doctesting] [testenv:doctesting]
basepython = python basepython = python
usedevelop = True
skipsdist = True skipsdist = True
# ensure the given pyargs can't mean anything else # ensure the given pyargs can't mean anything else
changedir = doc/ changedir = doc/
deps = deps =
PyYAML PyYAML
{env:_PYTEST_TOX_EXTRA_DEP:}
commands = commands =
pytest -ra en {env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra en
pytest --doctest-modules --pyargs _pytest {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest
[testenv:regen] [testenv:regen]
changedir = doc/en changedir = doc/en
@ -155,7 +173,8 @@ commands =
[testenv:py36-freeze] [testenv:py36-freeze]
changedir = testing/freeze changedir = testing/freeze
deps = pyinstaller deps =
pyinstaller
commands = commands =
{envpython} create_executable.py {envpython} create_executable.py
{envpython} tox_run.py {envpython} tox_run.py
@ -170,7 +189,7 @@ deps =
coveralls coveralls
codecov codecov
commands = commands =
coverage run --source=_pytest -m pytest testing coverage run -m pytest testing
coverage report -m coverage report -m
coveralls coveralls
codecov codecov