From 45d7f79abfbfc06ffabe8f3457de792845650e8f Mon Sep 17 00:00:00 2001 From: dzhuang Date: Sun, 3 Sep 2017 14:18:50 +0800 Subject: [PATCH] Fixed failed coverage for coveralls.io. Adding coverage report for Gitlab. --- .gitlab-ci.yml | 2 ++ .travis.yml | 3 +-- README.rst | 10 ++++++++-- run-coveralls.sh | 3 +-- run-tests-for-ci.sh | 6 +++++- setup.cfg | 41 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9406b9af..fb58f198 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ - python2.7 except: - tags + coverage: '/TOTAL.+ ([0-9]{1,3}%)/' Python 3.5: script: @@ -13,6 +14,7 @@ Python 3.5: - python3.5 except: - tags + coverage: '/TOTAL.+ ([0-9]{1,3}%)/' Documentation: script: diff --git a/.travis.yml b/.travis.yml index 17906f72..28d5c51b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +cache: pip python: - "2.7" - "3.5" @@ -7,5 +8,3 @@ script: - bash ./run-coveralls.sh env: - if [[$TRAVIS_PYTHON_VERSION = "2.7"]]; then PY_EXE=python2.7; else PY_EXE=python3.5; fi -after_success: - - coveralls \ No newline at end of file diff --git a/README.rst b/README.rst index b9f9f04d..e984c2b8 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,14 @@ .. image:: https://travis-ci.org/inducer/relate.svg - :target: https://travis-ci.org/inducer/relate + :target: https://travis-ci.org/inducer/relate .. image:: https://coveralls.io/repos/inducer/relate/badge.svg - :target: https://coveralls.io/r/inducer/relate + :target: https://coveralls.io/r/inducer/relate + +.. image:: https://gitlab.tiker.net/inducer/relate/badges/master/build.svg + :target: https://gitlab.tiker.net/inducer/relate/commits/master + +.. image:: https://gitlab.tiker.net/inducer/relate/badges/master/coverage.svg?job=Python+3.5 + RELATE ====== diff --git a/run-coveralls.sh b/run-coveralls.sh index 5db8c404..8a8a08fd 100644 --- a/run-coveralls.sh +++ b/run-coveralls.sh @@ -3,5 +3,4 @@ source $(dirname $0)/run-tests-for-ci.sh $PIP install coveralls - -coverage run --source=. manage.py test test/ +coveralls diff --git a/run-tests-for-ci.sh b/run-tests-for-ci.sh index 1e477cae..f330de3a 100644 --- a/run-tests-for-ci.sh +++ b/run-tests-for-ci.sh @@ -68,4 +68,8 @@ $PIP install -r req.txt cp local_settings.example.py local_settings.py -python manage.py test test/ +#python manage.py test test/ + +$PIP install coverage +coverage run --source=. manage.py test test/ +coverage report -m \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 4670a3c1..05106c25 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,3 +2,44 @@ ignore = E126,E127,E128,E123,E226,E241,E242,E265,E402,W503 max-line-length=85 exclude=course/migrations,accounts/migrations,static,components,course/mdx_mathjax.py + +[coverage:run] +branch=True +cover_pylib=False +omit = + */.env/* + */__init__.py + */virtualenv*/* + */setuptools*/* + */migrations/* + */mdx_mathjax.py + contrib/* + exercise-docker.py + update-attempt-ids.py + setup.py + local_settings.example.py + course/page/code_feedback.py + course/page/code_runpy_backend.py + */wsgi.py + */test/* + */tests.py + +[coverage:report] +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self.debug + if settings.Debug + + # 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_errors = True -- GitLab