Skip to content

Commit f0e852b

Browse files
authored
Merge pull request #2800 from blueyed/coverage
Travis: report coverage with all builds
2 parents 338953a + 417516c commit f0e852b

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

.coveragerc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[run]
2-
omit =
3-
# standlonetemplate is read dynamically and tested by test_genscript
4-
*standalonetemplate.py
2+
source = _pytest,testing
3+
parallel = 1

.travis.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ install:
1212
- pip install --upgrade --pre tox
1313
env:
1414
matrix:
15-
# coveralls is not listed in tox's envlist, but should run in travis
16-
- TOXENV=coveralls
1715
# note: please use "tox --listenvs" to populate the build matrix below
1816
# please remove the linting env in all cases
1917
- TOXENV=py27-pexpect
@@ -28,15 +26,16 @@ env:
2826
- TOXENV=py36-pluggymaster
2927
- TOXENV=py27-nobyte
3028
- TOXENV=doctesting
31-
- TOXENV=docs
29+
- TOXENV=docs PYTEST_NO_COVERAGE=1
3230

3331
jobs:
3432
include:
35-
- env: TOXENV=pypy
33+
# Coverage tracking is slow with pypy, skip it.
34+
- env: TOXENV=pypy PYTEST_NO_COVERAGE=1
3635
python: 'pypy-5.4'
3736
- env: TOXENV=py35
3837
python: '3.5'
39-
- env: TOXENV=py36-freeze
38+
- env: TOXENV=py36-freeze PYTEST_NO_COVERAGE=1
4039
python: '3.6'
4140
- env: TOXENV=py37
4241
python: '3.7'
@@ -62,7 +61,7 @@ jobs:
6261
env: TOXENV=py27
6362
- env: TOXENV=py34
6463
- env: TOXENV=py36
65-
- env: TOXENV=linting
64+
- env: TOXENV=linting PYTEST_NO_COVERAGE=1
6665

6766
- stage: deploy
6867
python: '3.6'
@@ -80,8 +79,32 @@ jobs:
8079
tags: true
8180
repo: pytest-dev/pytest
8281

82+
before_script:
83+
- |
84+
if [[ "$PYTEST_NO_COVERAGE" != 1 ]]; then
85+
export _PYTEST_TOX_COVERAGE_RUN="env COVERAGE_FILE=$PWD/.coverage COVERAGE_PROCESS_START=$PWD/.coveragerc coverage run --source {envsitepackagesdir}/_pytest/,$PWD/testing -m"
86+
export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess
87+
fi
88+
8389
script: tox --recreate
8490

91+
after_success:
92+
- |
93+
if [[ "$PYTEST_NO_COVERAGE" != 1 ]]; then
94+
set -e
95+
pip install codecov
96+
coverage combine
97+
coverage xml
98+
coverage report -m
99+
codecov --required -X gcov pycov search -f coverage.xml --flags ${TOXENV//-/ }
100+
101+
# Coveralls does not support merged reports.
102+
if [[ "$TOXENV" = py37 ]]; then
103+
pip install coveralls
104+
coveralls
105+
fi
106+
fi
107+
85108
notifications:
86109
irc:
87110
channels:

tox.ini

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@ envlist =
1717
docs
1818

1919
[testenv]
20-
commands = pytest --lsof -ra {posargs:testing}
20+
commands =
21+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest --lsof -ra {env:_PYTEST_TEST_OPTS:} {posargs:testing}
22+
coverage: coverage report -m --skip-covered
23+
setenv =
24+
coverage: _PYTEST_TOX_COVERAGE_RUN=coverage run -m
25+
coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess
26+
coverage: COVERAGE_FILE={toxinidir}/.coverage
27+
coverage: COVERAGE_PROCESS_START={toxinidir}/.coveragerc
2128
passenv = USER USERNAME
2229
deps =
2330
hypothesis>=3.56
2431
nose
2532
mock
2633
requests
34+
{env:_PYTEST_TOX_EXTRA_DEP:}
2735

2836
[testenv:py27-subprocess]
2937
changedir = .
@@ -47,9 +55,10 @@ deps =
4755
mock
4856
nose
4957
hypothesis>=3.56
58+
{env:_PYTEST_TOX_EXTRA_DEP:}
5059
changedir=testing
5160
commands =
52-
pytest -n8 -ra {posargs:.}
61+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n8 -ra {posargs:.}
5362

5463
[testenv:py36-xdist]
5564
deps = {[testenv:py27-xdist]deps}
@@ -58,9 +67,11 @@ commands = {[testenv:py27-xdist]commands}
5867
[testenv:py27-pexpect]
5968
changedir = testing
6069
platform = linux|darwin
61-
deps = pexpect
70+
deps =
71+
pexpect
72+
{env:_PYTEST_TOX_EXTRA_DEP:}
6273
commands =
63-
pytest -ra test_pdb.py test_terminal.py test_unittest.py
74+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra test_pdb.py test_terminal.py test_unittest.py
6475

6576
[testenv:py36-pexpect]
6677
changedir = {[testenv:py27-pexpect]changedir}
@@ -73,33 +84,40 @@ deps =
7384
pytest-xdist>=1.13
7485
hypothesis>=3.56
7586
mock
87+
{env:_PYTEST_TOX_EXTRA_DEP:}
7688
distribute = true
7789
changedir=testing
7890
setenv =
91+
{[testenv]setenv}
7992
PYTHONDONTWRITEBYTECODE=1
8093
commands =
81-
pytest -n3 -ra {posargs:.}
94+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest -n3 -ra {posargs:.}
8295

8396
[testenv:py27-trial]
84-
deps = twisted
97+
deps =
98+
twisted
99+
{env:_PYTEST_TOX_EXTRA_DEP:}
85100
commands =
86-
pytest -ra {posargs:testing/test_unittest.py}
101+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra {posargs:testing/test_unittest.py}
87102

88103
[testenv:py36-trial]
89104
deps = {[testenv:py27-trial]deps}
90105
commands = {[testenv:py27-trial]commands}
91106

92107
[testenv:py27-numpy]
93-
deps = numpy
108+
deps =
109+
numpy
110+
{env:_PYTEST_TOX_EXTRA_DEP:}
94111
commands=
95-
pytest -ra {posargs:testing/python/approx.py}
112+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra {posargs:testing/python/approx.py}
96113

97114
[testenv:py36-numpy]
98115
deps = {[testenv:py27-numpy]deps}
99116
commands = {[testenv:py27-numpy]commands}
100117

101118
[testenv:py27-pluggymaster]
102119
setenv=
120+
{[testenv]setenv}
103121
_PYTEST_SETUP_SKIP_PLUGGY_DEP=1
104122
deps =
105123
{[testenv]deps}
@@ -123,15 +141,13 @@ commands =
123141

124142
[testenv:doctesting]
125143
basepython = python
126-
usedevelop = True
127144
skipsdist = True
128-
# ensure the given pyargs can't mean anything else
129-
changedir = doc/
130145
deps =
131146
PyYAML
147+
{env:_PYTEST_TOX_EXTRA_DEP:}
132148
commands =
133-
pytest -ra en
134-
pytest --doctest-modules --pyargs _pytest
149+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest -ra doc/en
150+
{env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest
135151

136152
[testenv:regen]
137153
changedir = doc/en
@@ -155,7 +171,8 @@ commands =
155171

156172
[testenv:py36-freeze]
157173
changedir = testing/freeze
158-
deps = pyinstaller
174+
deps =
175+
pyinstaller
159176
commands =
160177
{envpython} create_executable.py
161178
{envpython} tox_run.py
@@ -170,7 +187,7 @@ deps =
170187
coveralls
171188
codecov
172189
commands =
173-
coverage run --source=_pytest -m pytest testing
190+
coverage run -m pytest testing
174191
coverage report -m
175192
coveralls
176193
codecov

0 commit comments

Comments
 (0)