diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000000..4c6997a8a8 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,84 @@ +# ----------------------------------------------------------------------------- +# (C) British Crown Copyright 2012-8 Met Office. +# +# This file is part of Rose, a framework for meteorological suites. +# +# Rose is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Rose is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Rose. If not, see . +# ----------------------------------------------------------------------------- + +# This is the Coverage.py configuration file. This is used by Travis-CI when running +# the tests and collecting coverage + +[run] + +branch=True +cover_pylib=False +concurrency=thread +data_file=${TRAVIS_BUILD_DIR}/.coverage +disable_warnings= +debug= +# callers +# dataio +# multiprocess +# dataio +# dataop +# pid +# plugin +# process +# sys +# trace +# Include can be used only if source is not used! +#include +note= +omit= + */lib/python/isodatetime* +parallel = False +plugins= +source= + ./bin + ./lib/python +timid = False + + +[report] + +exclude_lines = + pragma: no cover + def __repr__ + raise NotImplementedError + if __name__ == .__main__.: + def parse_args +fail_under=0 +ignore_errors = False +include= +omit= + */lib/python/isodatetime* +partial_branches= +precision=2 +show_missing=False +skip_covered=False +sort=Name + + +[html] + +directory=htmlcov +extra_css= +title= + + +[xml] + +output=coverage.xml +package_depth=99 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 638180e769..707f1eb2c8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,9 @@ etc/opt lib/bash/rose_init_site doc venv + +# coverage +.coverage +.coverage.* +coverage.xml +htmlcov/ diff --git a/.travis.yml b/.travis.yml index 6e8217090a..a6547bd639 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,10 @@ before_install: - ssh-keygen -t 'rsa' -f "${HOME}/.ssh/id_rsa" -N '' -q - cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys" - ssh-keyscan -t 'rsa' 'localhost' >>"${HOME}/.ssh/known_hosts" + # Coverage dependencies + - pip install coverage pytest-cov -install: +install: - > sudo apt-get install -y at build-essential gfortran heirloom-mailx python-pip python-dev graphviz libgraphviz-dev python-jinja2 @@ -32,14 +34,16 @@ install: - sudo apt-get update - sudo apt-get install -y subversion -script: skip - jobs: include: - stage: test - - script: > - rose test-battery --state=save -j 5 || - (echo -e "\n\nRerunning Failed Tests...\n\n"; - rose test-battery -v --state=save,failed -j 5) - - script: > - rose make-docs --venv --dev --strict clean linkcheck doctest html slides latexpdf + - script: + - export COVERAGE_PROCESS_START="${TRAVIS_BUILD_DIR}/.coveragerc" + - export PYTHONPATH="${TRAVIS_BUILD_DIR}/.travis" + - coverage run .travis/cover.py + - unset PYTHONPATH + - script: + - rose make-docs --venv --dev --strict clean linkcheck doctest html slides latexpdf + - after_success: + - coverage xml --ignore-errors + - bash <(curl -s https://codecov.io/bash) diff --git a/.travis/cover.py b/.travis/cover.py new file mode 100644 index 0000000000..d3e9344194 --- /dev/null +++ b/.travis/cover.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# ----------------------------------------------------------------------------- +# (C) British Crown Copyright 2012-8 Met Office. +# +# This file is part of Rose, a framework for meteorological suites. +# +# Rose is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Rose is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Rose. If not, see . +# ----------------------------------------------------------------------------- + +from subprocess import call + + +def main(): + call( + 'rose test-battery --state=save -j 5 || (echo -e "\n\nRerunning Failed Tests...\n\n"; rose test-battery -v --state=save,failed -j 5)', + shell=True) + + +if __name__ == '__main__': + main() diff --git a/.travis/sitecustomize.py b/.travis/sitecustomize.py new file mode 100644 index 0000000000..9328aacce1 --- /dev/null +++ b/.travis/sitecustomize.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# ----------------------------------------------------------------------------- +# (C) British Crown Copyright 2012-8 Met Office. +# +# This file is part of Rose, a framework for meteorological suites. +# +# Rose is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Rose is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Rose. If not, see . +# ----------------------------------------------------------------------------- + +"""This file is used by Travis-CI to start the coverage process. In order to make +Python aware of it, we export PYTHONPATH when running the tests""" + + +import coverage + +coverage.process_startup()