Skip to content

Commit

Permalink
add coverage to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Nov 27, 2020
1 parent 358d70e commit f6abf51
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[run]
plugins = Cython.Coverage
parallel = True
branch = False
omit =
zmq/eventloop/minitornado/*
zmq/tests/*

[report]
exclude_lines =
pragma: no cover
ignore_errors = True
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

env:
FORCE_COLOR: "1"
PYZMQ_CYTHON_COVERAGE: "1"

jobs:
lint:
Expand Down Expand Up @@ -89,6 +90,12 @@ jobs:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch || 'x64' }}

- name: setup coverage
if: startsWith(matrix.python, 'pypy')
run: |
grep -v plugins .coveragerc > .coveragerc-pypy
mv .coveragerc-pypy .coveragerc
- name: install dependencies
run: |
pip install --upgrade pip wheel
Expand Down Expand Up @@ -165,7 +172,10 @@ jobs:
- name: run tests
run: |
python -m pytest -m "not new_console" -v zmq/tests
python -m pytest --cov zmq -m "not new_console" -v zmq/tests
- name: upload coverage
run: codecov

# FIXME: what's the right incantation to call this?
# the same line from appveyor doesn't work here
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ venv
*.code-workspace
.vscode
.mypy_cache
.coverage
htmlcov
coverage.xml
env
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
comment: off
# show coverage in CI status, but never consider it a failure
coverage:
status:
project:
default:
target: 0%
patch:
default:
target: 0%
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ def init_settings_from_config(self):
if use_static_zmq in ('TRUE', '1'):
settings['define_macros'].append(('ZMQ_STATIC', '1'))

if os.environ.get("PYZMQ_CYTHON_COVERAGE"):
settings['define_macros'].append(('CYTHON_TRACE', '1'))

# include internal directories
settings.setdefault('include_dirs', [])
settings['include_dirs'] += [pjoin('zmq', sub) for sub in ('utils',)]
Expand Down Expand Up @@ -1326,6 +1329,7 @@ def finalize_options(self):
'include_dirs': ext_include_dirs,
}


for submod, packages in submodules.items():
for pkg in sorted(packages):
sources = [pjoin("zmq", submod.replace(".", os.path.sep), pkg + suffix)]
Expand All @@ -1336,6 +1340,8 @@ def finalize_options(self):
# set binding so that compiled methods can be inspected
# set language-level to 3str, requires Cython 0.29
cython_directives = {"binding": True, "language_level": "3str"}
if os.environ.get("PYZMQ_CYTHON_COVERAGE"):
cython_directives["linetrace"] = True
extensions = cythonize(extensions, compiler_directives=cython_directives)

if pypy:
Expand Down
4 changes: 4 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# gevent wheels on mac cause Illegal Instruction
codecov
# coverage 5 has issues with Cython: https://github.com/cython/cython/issues/3515
coverage<5
gevent; platform_python_implementation != "PyPy" and sys_platform != "win32" and sys_platform != "darwin"
pytest
pytest-cov
pytest-rerunfailures
tornado
mypy; platform_python_implementation != "PyPy"
Expand Down

0 comments on commit f6abf51

Please sign in to comment.