Skip to content

Commit

Permalink
Use tox for testing, add coverage testing
Browse files Browse the repository at this point in the history
  • Loading branch information
madig committed Jun 17, 2019
1 parent 51bbef7 commit e56bc65
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 14 deletions.
32 changes: 32 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[run]
# measure 'branch' coverage in addition to 'statement' coverage
# See: http://coverage.readthedocs.org/en/coverage-4.0.3/branch.html#branch
branch = True
parallel = True
omit = tests/*

# list of directories or packages to measure
source = fontmake

# these are treated as equivalent when combining data
[paths]
source =
Lib/fontmake
*/site-packages/fontmake

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# keywords to use in inline comments to skip coverage
pragma: no cover

# don't complain if tests don't hit defensive assertion code
raise AssertionError
raise NotImplementedError

# don't complain if non-runnable code isn't run
if 0:
if __name__ == .__main__.:

# ignore source code that can’t be found
ignore_errors = True
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# to native line endings on checkout.
*.cfg text
*.in text
*.ini text
*.md text
*.py text
*.rst text
Expand Down
30 changes: 17 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
sudo: false
language: python
dist: xenial

env:
global:
- TWINE_USERNAME="anthrotype"
- secure: wg1vkiWvySib0Zz37R4GZyHEcW84774P09NuT8B7EyAH2McGSmCw8SrbwqzLx8VIayr7hw5ttTSrU2mSf1oapZzhRvetAW3FvaUqlBLfDIXUFbbsMXUgEPIiaahaxmjhAKHkLcZEKJyyzHwAXzCVF1KTE7z4UmjEy0whl4Tf4MP+0OSbTKcTqxNYIWj/IWn22lt8zjtoUdWFR/qmzX/WPtgOLT49CkXKOPLdndohDOjQqiALq07ofiyeL+zBYqIT/OYsX1w+bkaI1Rbj4ovr0MRPprs6Vf/s9qcyarVQgUmeSCwQDarDx5nC+hLnSY+6k8Tk4xQC94QE0LmKvCcNMQFZ/qcP5YJ4oKZJ0nIjEwktpRGLQzrHrTKqNHGMiBtRvwn1t/P8Wpl+KfbB6BjvkjzSGsLrWmzhX247zppy4u+wC4eozItgrTyHvo5Zv1BSYGlC9P9ql/pmFCt0N1Wnfal0trLTQAWS03Tt0m7Tv94Ss7LWlRqJWsOUsK2Jrygyr53ParRX4E96ho8vMGM1OWqrpaFEnYGRt5gp2SHrwBVUdJCUybw5RKH+npAG/8B0gvewGy9nSoo8+T/BYPKM41105Ses7O3ucKcgFy9NWunJYHPwQZLy5YPF9UdcKKa3Vdgm0oB8C6Qew2wYNftJXBmsJI2QtNTJBNHzY1xlNeo=

python:
- "2.7"
- "3.6"

cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/pre-commit

language: python

matrix:
include:
- python: 3.7
env: TOXENV=lint
- python: 3.6
env: TOXENV=py36-cov
- python: 3.7
env: TOXENV=py37-cov

install:
- pip install --upgrade pip
- pip install -r test_requirements.txt .
- pip install tox

script:
- |
if [ "$TRAVIS_PYTHON_VERSION" == "3.6" ]; then pip install --upgrade pre-commit && pre-commit run --all-files --show-diff-on-failure; fi
- (cd test && ./run.sh)
- tox

after_success:
- |
if [ -n "$TRAVIS_TAG" ] && [ "$TRAVIS_REPO_SLUG" == "googlefonts/fontmake" ] && [ "$TRAVIS_PYTHON_VERSION" == "3.6" ]; then
if [ -n "$TRAVIS_TAG" ] && [ "$TRAVIS_REPO_SLUG" == "googlefonts/fontmake" ] && [ "$TOXENV" == "py37-cov" ]; then
pip install --upgrade pip
pip install --upgrade twine setuptools wheel shiv
python setup.py sdist
Expand All @@ -46,4 +50,4 @@ deploy:
repo: googlefonts/fontmake
tags: true
all_branches: true
python: 3.6
python: 3.7
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ ignore = E203, E266, E501, W503
max-line-length = 80
max-complexity = 21
exclude = .git, __pycache__, build, dist, .eggs, .tox

[tool:pytest]
filterwarnings =
ignore:fromstring:DeprecationWarning
ignore:tostring:DeprecationWarning
3 changes: 2 additions & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-r requirements.txt
mock==2.0.0; python_version < "3.3"
pytest>=4.5.0
pytest-cov>=2.7
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# More info on pytest-cov integration: https://pytest-cov.readthedocs.io/en/latest/tox.html
# Coverage is intentionally not appended to each run because we do not have a coverage
# service set up, it should be used by the developer for local runs only.

[tox]
envlist = lint, py{36,37}-cov, coverage-report

[testenv]
deps =
-r test_requirements.txt
commands =
pytest --cov fontmake {posargs}

[testenv:lint]
skip_install = true
deps = pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure
python -c 'print(r"hint: run {envdir}/bin/pre-commit or {envdir}/Scripts/pre-commit install to add checks as pre-commit hook")'

[testenv:coverage-report]
skip_install = true
commands =
coverage html

0 comments on commit e56bc65

Please sign in to comment.