diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ff0350e4e..8232620e35 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,6 +21,10 @@ commands: circleci step halt fi test_and_report: + parameters: + args: + type: string + default: "" steps: - run: name: Run tests @@ -28,7 +32,7 @@ commands: mkdir -p test-reports . /opt/conda/etc/profile.d/conda.sh conda activate esmvaltool - pytest -n 4 --junitxml=test-reports/report.xml + pytest -n 4 --junitxml=test-reports/report.xml << parameters.args >> esmvaltool version - store_test_results: path: test-reports/report.xml @@ -127,8 +131,9 @@ jobs: . /opt/conda/etc/profile.d/conda.sh mkdir /logs conda activate esmvaltool - pip install .[test] |& tee -a /logs/install.txt - - test_and_report + pip install .[test] > /logs/install.txt 2>&1 + - test_and_report: + args: --cov - save_cache: key: test-{{ .Branch }}-{{ checksum "cache_key.txt" }} paths: diff --git a/doc/contributing.rst b/doc/contributing.rst index a21a005e72..8737fda13e 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -470,9 +470,16 @@ successful. Test coverage ~~~~~~~~~~~~~ -To check which parts of your code are `covered by unit tests`_, open the file -``test-reports/coverage_html/index.html`` (available after running a ``pytest`` -command) and browse to the relevant file. +To check which parts of your code are `covered by unit tests`_, run the command + +.. code-block:: bash + + pytest --cov + +and open the file ``test-reports/coverage_html/index.html`` and browse to the +relevant file. Note that tracking code coverage slows down the test runs, +therefore it is disabled by default and needs to be requested by providing +``pytest`` with the ``--cov`` flag. CircleCI will upload the coverage results from running the tests to codecov and Codacy. diff --git a/setup.cfg b/setup.cfg index 15d02392d7..995fd69c9e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,6 @@ addopts = --doctest-modules --ignore=esmvalcore/cmor/tables/ - --cov=esmvalcore --cov-report=xml:test-reports/coverage.xml --cov-report=html:test-reports/coverage_html --html=test-reports/report.html @@ -15,6 +14,7 @@ markers = [coverage:run] parallel = true +source = esmvalcore [coverage:report] exclude_lines = pragma: no cover