Skip to content

Commit

Permalink
Simplify and fix coverage issues with some configurations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Jan 12, 2019
1 parent 76042c7 commit 7f4462f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 258 deletions.
4 changes: 2 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def replace_contents(filename, what, replacement):
os.unlink(join('src', '{{ cookiecutter.package_name }}', 'cli.py'))
{% endif %}

{%- if cookiecutter.test_matrix_configurator == 'no' and cookiecutter.test_matrix_separate_coverage == 'no' %}
{%- if cookiecutter.test_matrix_configurator == 'no' %}
os.unlink(join('ci', 'templates', 'tox.ini'))
{% endif %}

Expand Down Expand Up @@ -122,7 +122,7 @@ def replace_contents(filename, what, replacement):
You can also run:
ci/bootstrap.py
./ci/bootstrap.py
{% else %}
The project doesn't use the test matrix configurator, but in case
you change your mind just edit `setup.cfg` and run `ci/bootstrap.py`.
Expand Down
14 changes: 7 additions & 7 deletions {{cookiecutter.repo_name}}/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ environment:
WITH_COMPILER: 'cmd /E:ON /V:ON /C .\ci\appveyor-with-compiler.cmd'
matrix:
- TOXENV: check
TOXPYTHON: C:\Python27\python.exe
PYTHON_HOME: C:\Python27
PYTHON_VERSION: '2.7'
TOXPYTHON: C:\Python36\python.exe
PYTHON_HOME: C:\Python36
PYTHON_VERSION: '3.6'
PYTHON_ARCH: '32'
{%- for env in ['py27', 'py34', 'py35', 'py36', 'py37'] %}{{ '' }}
- TOXENV: '{{ env }}{% if cookiecutter.test_matrix_separate_coverage == 'yes' %}-cover{% endif -%},report
Expand All @@ -23,9 +23,9 @@ environment:
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif %}'
TOXPYTHON: C:\Python{{ env[2:4] }}-x64\python.exe
{% if env.startswith(('py2', 'py34')) -%}
{%- if env.startswith(('py2', 'py34')) %}
WINDOWS_SDK_VERSION: v7.{{ '1' if env.startswith('py3') else '0' }}
{% endif -%}
{%- endif %}
PYTHON_HOME: C:\Python{{ env[2:4] }}-x64
PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}'
PYTHON_ARCH: '64'
Expand All @@ -37,9 +37,9 @@ environment:
PYTHON_ARCH: '32'
- TOXENV: '{{ env }}-nocov'
TOXPYTHON: C:\Python{{ env[2:4] }}-x64\python.exe
{% if env.startswith(('py2', 'py34')) -%}
{%- if env.startswith(('py2', 'py34')) %}
WINDOWS_SDK_VERSION: v7.{{ '1' if env.startswith('py3') else '0' }}
{% endif -%}
{%- endif %}
PYTHON_HOME: C:\Python{{ env[2:4] }}-x64
PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}'
PYTHON_ARCH: '64'
Expand Down
82 changes: 35 additions & 47 deletions {{cookiecutter.repo_name}}/ci/templates/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,51 @@ environment:
WITH_COMPILER: 'cmd /E:ON /V:ON /C .\ci\appveyor-with-compiler.cmd'
matrix:
- TOXENV: check
TOXPYTHON: C:\Python27\python.exe
PYTHON_HOME: C:\Python27
PYTHON_VERSION: '2.7'
TOXPYTHON: C:\Python36\python.exe
PYTHON_HOME: C:\Python36
PYTHON_VERSION: '3.6'
PYTHON_ARCH: '32'
{% if cookiecutter.test_matrix_configurator == "yes" %}
{%- raw -%}
{% for env, config in tox_environments|dictsort %}{{ '' }}{% if env.startswith(('py2', 'py3')) %}
- TOXENV: '{{ env }}{% endraw %}{% if cookiecutter.codecov == 'yes' %}{% raw %}{% if config.cover %}{% endraw -%},report
{% if cookiecutter.test_matrix_configurator == "yes" -%}
{{ "{% for env, config in tox_environments|dictsort %}" }}
{%- else -%}
{{ "{% for env in tox_environments %}" }}
{%- endif -%}
{{ "{{ '' }}{% if env.startswith(('py2', 'py3')) %}" }}
- TOXENV: {{ "'{{ env }}" }}
{%- if cookiecutter.test_matrix_separate_coverage == "yes" -%}
{%- if cookiecutter.test_matrix_configurator == "yes" -%}
{{ "{% if config.cover %}" }}
{%- else -%}
{{ "{% if env.endswith('-cover') %}" }}
{%- endif -%}
{%- endif -%}
,report
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif %}
{%- raw %}{% endif %}{%- endraw %}{% endif %}{% raw %}'
{%- if cookiecutter.test_matrix_separate_coverage == "yes" -%}
{{ "{% endif %}" }}
{%- endif %}{{ "'" }}
{%- raw %}
TOXPYTHON: C:\Python{{ env[2:4] }}\python.exe
PYTHON_HOME: C:\Python{{ env[2:4] }}
PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}'
PYTHON_ARCH: '32'
- TOXENV: '{{ env }}{% endraw -%}{% if cookiecutter.codecov == 'yes' -%}{% raw %}{% if config.cover %}{% endraw -%},report
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif -%}
{%- raw %}{% endif %}{% endraw %}{% endif %}{% raw %}'
TOXPYTHON: C:\Python{{ env[2:4] }}-x64\python.exe
{%- if env.startswith(('py2', 'py34')) %}

WINDOWS_SDK_VERSION: v7.{{ '1' if env.startswith('py3') else '0' }}
{%- endif %}

PYTHON_HOME: C:\Python{{ env[2:4] }}-x64
PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}'
PYTHON_ARCH: '64'

{% endif %}{% endfor %}
{%- endraw %}
{% else %}
{%- raw -%}
{% for env in tox_environments %}{{ '' }}{% if env.startswith(('py2', 'py3')) %}
- TOXENV: '{{ env }}{% endraw %}{% if cookiecutter.test_matrix_separate_coverage == 'yes' %}{% raw %}{% if 'cover' in env %}{% endraw %},report
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif %}
{%- raw %}{% endif %}{%- endraw -%}
{%- else -%},report
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif -%}
{%- endif -%}
{%- raw %}'
TOXPYTHON: C:\Python{{ env[2:4] }}\python.exe
PYTHON_HOME: C:\Python{{ env[2:4] }}
PYTHON_VERSION: '{{ env[2] }}.{{ env[3] }}'
PYTHON_ARCH: '32'
- TOXENV: '{{ env }}{% endraw %}{% if cookiecutter.test_matrix_separate_coverage == 'yes' %}{% raw %}{% if 'cover' in env %}{% endraw %},report
- TOXENV: {{ "'{{ env }}" }}
{%- if cookiecutter.test_matrix_separate_coverage == "yes" -%}
{%- if cookiecutter.test_matrix_configurator == "yes" -%}
{{ "{% if config.cover %}" }}
{%- else -%}
{{ "{% if env.endswith('-cover') %}" }}
{%- endif -%}
{%- endif -%}
,report
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif %}
{%- raw %}{%- endif %}{%- endraw -%}
{%- else -%},report
{#- if cookiecutter.coveralls == 'yes' %},coveralls{% endif -#}
{%- if cookiecutter.codecov == 'yes' %},codecov{% endif -%}
{%- endif -%}
{%- raw %}'
{%- if cookiecutter.test_matrix_separate_coverage == "yes" -%}
{{ "{% endif %}" }}
{%- endif %}{{ "'" }}
{%- raw %}
TOXPYTHON: C:\Python{{ env[2:4] }}-x64\python.exe
{%- if env.startswith(('py2', 'py34')) %}

Expand All @@ -74,7 +63,6 @@ environment:
PYTHON_ARCH: '64'
{% endif %}{% endfor %}
{%- endraw %}
{% endif -%}
init:
- ps: echo $env:TOXENV
- ps: ls C:\Python*
Expand Down
198 changes: 18 additions & 180 deletions {{cookiecutter.repo_name}}/ci/templates/tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{%- if cookiecutter.test_matrix_configurator == "yes" -%}
[tox]
envlist =
clean,
Expand Down Expand Up @@ -26,17 +25,31 @@ deps =
{%- if cookiecutter.test_runner == "pytest" %}
pytest
pytest-travis-fold
{%- if cookiecutter.test_matrix_separate_coverage == 'no' %}
pytest-cov
{%- endif %}
{%- else %}
nose
{%- if cookiecutter.test_matrix_separate_coverage == 'no' %}
coverage
{%- endif %}
{%- endif %}
commands =
{%- if cookiecutter.c_extension_support != "no" %}
python setup.py clean --all build_ext --force --inplace
{%- endif %}
{%- if cookiecutter.test_runner == "pytest" %}
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}
{posargs:pytest -vv --ignore=src}
{%- else %}
{posargs:pytest --cov --cov-report=term-missing -vv --ignore=src}
{%- endif %}
{%- else %}
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}
{posargs:nosetests -v tests}
{%- else %}
{posargs:nosetests --with-coverage --cover-package={{ cookiecutter.package_name}} tests}
{%- endif %}
{%- endif %}

[testenv:bootstrap]
Expand Down Expand Up @@ -142,8 +155,8 @@ commands =
commands = coverage erase
skip_install = true
deps = coverage

{% for env, config in tox_environments|dictsort %}

[testenv:{{ env }}]
basepython = {env:TOXPYTHON:{{ env.split("-")[0] if env.startswith("pypy") else "python{0[2]}.{0[3]}".format(env) }}}
{% if config.cover or config.env_vars %}
Expand Down Expand Up @@ -187,181 +200,6 @@ deps =
{% endif %}
{% for dep in config.deps %}
{{ dep }}
{% endfor %}

{% endfor %}

{% endraw %}
{%- else -%}
; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist

[tox]
envlist =
clean,
check,
{%- if cookiecutter.sphinx_docs == "yes" %}
docs,
{%- endif %}
{py27,py34,py35,py36,py37,pypy,pypy3}{% if cookiecutter.test_matrix_separate_coverage == 'yes' %}-{cover,nocov}{% endif %},
report

[testenv]
basepython =
pypy: {env:TOXPYTHON:pypy}
pypy3: {env:TOXPYTHON:pypy3}
{% if cookiecutter.sphinx_docs == "yes" %}{py27,docs,spell}{% else %}py27{% endif %}: {env:TOXPYTHON:python2.7}
py34: {env:TOXPYTHON:python3.4}
py35: {env:TOXPYTHON:python3.5}
py36: {env:TOXPYTHON:python3.6}
py37: {env:TOXPYTHON:python3.7}
{bootstrap,clean,check,report{%- if cookiecutter.codecov == 'yes' %},codecov{% endif %}{% if cookiecutter.coveralls == 'yes' %},coveralls{% if cookiecutter.c_extension_support != "no" %},extension-coveralls{% endif %}{% endif %}}: {env:TOXPYTHON:python3}
setenv =
PYTHONPATH={toxinidir}/tests
PYTHONUNBUFFERED=yes
passenv =
*
usedevelop = false
deps =
{%- if cookiecutter.test_runner == "pytest" %}
pytest
pytest-travis-fold
{% if cookiecutter.test_matrix_separate_coverage == 'yes' %}cover: {% endif %}pytest-cov
{%- else %}
nose
{% if cookiecutter.test_matrix_separate_coverage == 'yes' %}cover: {% endif %}coverage
{%- endif %}
commands =
{%- if cookiecutter.c_extension_support != "no" %}
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}
cover: python setup.py clean --all build_ext --force --inplace
{%- endif %}
{%- endif %}
{%- if cookiecutter.test_runner == "pytest" %}
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}
nocov: {posargs:pytest -vv --ignore=src}
cover: {posargs:pytest --cov --cov-report=term-missing -vv}
{%- else %}
{posargs:pytest --cov --cov-report=term-missing -vv tests}
{%- endif %}
{%- else %}
{%- if cookiecutter.test_matrix_separate_coverage == 'yes' %}
nocov: {posargs:nosetests -v tests}
cover: {posargs:nosetests --with-coverage --cover-package={{ cookiecutter.package_name }}}
{%- else %}
{posargs:nosetests --with-coverage --cover-package={{ cookiecutter.package_name}} tests}
{%- endif %}
{%- endif %}

[testenv:bootstrap]
deps =
jinja2
matrix
skip_install = true
commands =
python ci/bootstrap.py

[testenv:check]
deps =
docutils
check-manifest
{%- if cookiecutter.linter == "flake8" %}
flake8
{%- else %}
pylama
{%- endif %}
readme-renderer
pygments
isort
skip_install = true
commands =
python setup.py check --strict --metadata --restructuredtext
check-manifest {toxinidir}
{%- if cookiecutter.linter == "flake8" %}
flake8 src tests setup.py
{%- else %}
pylama src tests setup.py
{%- endif %}
isort --verbose --check-only --diff --recursive src tests setup.py
{%- if cookiecutter.c_extension_support == 'cython' %}

[testenv:cythonize]
basepython = {env:TOXPYTHON:python}
deps =
Cython
skip_install = true
commands =
python setup.py build
{%- endif %}
{%- if cookiecutter.sphinx_docs == "yes" %}

[testenv:spell]
setenv =
SPELLCHECK=1
commands =
sphinx-build -b spelling docs dist/docs
skip_install = true
deps =
-r{toxinidir}/docs/requirements.txt
sphinxcontrib-spelling
pyenchant

[testenv:docs]
deps =
-r{toxinidir}/docs/requirements.txt
commands =
{%- if cookiecutter.sphinx_doctest == "yes" %}
sphinx-build {posargs:-E} -b doctest docs dist/docs
{%- endif %}
sphinx-build {posargs:-E} -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
{%- endif %}
{%- if cookiecutter.coveralls == 'yes' %}

[testenv:coveralls]
deps =
coveralls
skip_install = true
commands =
coveralls{%- if cookiecutter.c_extension_support != "no" %} --merge=extension-coveralls.json{% endif %} []
{%- if cookiecutter.c_extension_support != "no" %}

[testenv:extension-coveralls]
deps =
cpp-coveralls
skip_install = true
commands =
coveralls --build-root=. --include=src --dump=extension-coveralls.json []
{%- endif %}
{%- endif %}
{%- if cookiecutter.codecov == 'yes' %}

[testenv:codecov]
deps =
codecov
skip_install = true
commands =
coverage xml --ignore-errors
codecov []
{%- endif %}

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

[testenv:clean]
commands = coverage erase
skip_install = true
deps = coverage
{%- raw %}
{% for env in tox_environments %}
{% if 'cover' in env %}

[testenv:{{ env }}]
usedevelop = true
{% endif %}
{% endfor %}
{%- endraw %}
{%- endif %}
{% endfor -%}
{% endfor -%}
{% endraw -%}
Loading

0 comments on commit 7f4462f

Please sign in to comment.