Skip to content

Commit

Permalink
Disable collecting test coverage by default (#2456)
Browse files Browse the repository at this point in the history
Co-authored-by: Valeriu Predoi <[email protected]>
  • Loading branch information
bouweandela and valeriupredoi authored Oct 14, 2024
1 parent bd36519 commit 7ff491c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
11 changes: 8 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ commands:
circleci step halt
fi
test_and_report:
parameters:
args:
type: string
default: ""
steps:
- run:
name: Run tests
command: |
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
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 10 additions & 3 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,6 +14,7 @@ markers =

[coverage:run]
parallel = true
source = esmvalcore
[coverage:report]
exclude_lines =
pragma: no cover
Expand Down

0 comments on commit 7ff491c

Please sign in to comment.