diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..5688fe4a --- /dev/null +++ b/.coveragerc @@ -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 diff --git a/.gitattributes b/.gitattributes index 7b20b0b8..e0931d21 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,7 @@ # to native line endings on checkout. *.cfg text *.in text +*.ini text *.md text *.py text *.rst text diff --git a/.travis.yml b/.travis.yml index 476acec2..15ac5ed5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -46,4 +50,4 @@ deploy: repo: googlefonts/fontmake tags: true all_branches: true - python: 3.6 + python: 3.7 diff --git a/setup.cfg b/setup.cfg index b0c0bcb4..1f60f136 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/test_requirements.txt b/test_requirements.txt index cb3c3bdf..8a14f483 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,2 +1,3 @@ -r requirements.txt -mock==2.0.0; python_version < "3.3" +pytest>=4.5.0 +pytest-cov>=2.7 diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..cecbce67 --- /dev/null +++ b/tox.ini @@ -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