Skip to content

Commit fecc8b8

Browse files
committed
test: do not generate a coverage report from tox
if we would the files would be relative to the tox virtual environments and prefixed with '.tox/py*/lib/python*/site-packages/' - which makes them interesting to look at but useless for consumption by other tools
1 parent 8bffbec commit fecc8b8

File tree

3 files changed

+31
-27
lines changed

3 files changed

+31
-27
lines changed

docs/CONTRIBUTING.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,33 @@ done
3737
pdm install
3838
```
3939

40-
### perform unit tests:
40+
### testing
41+
42+
The entire test suite (unit tests & compatibility tests) can be triggered
43+
by running
4144

4245
```SHELL
43-
pdm run pytest
46+
scripts/run_tests
4447
```
4548

46-
### perform compatibility tests:
49+
You have successfully run all tests when the output ends with:
4750

48-
```SHELL
49-
tox
5051
```
52+
----------------------------------------------------------------------
53+
If you reached this far you passed. Congratulations!
54+
----------------------------------------------------------------------
55+
```
56+
57+
If the unit tests have run successfully coverage file in LCOV format is
58+
generated and stored at `coverage/lcov.info`. This file can be used by
59+
your IDE to indicate code coverage from within your editor window.
60+
- We recommend the Visual Studio Code extension
61+
[Code Coverage](https://marketplace.visualstudio.com/items?itemName=markis.code-coverage).
62+
- Special care should be taken when modifying code that is not covered by unit tests!
63+
64+
Branches that do not pass the test harness (e.g. due to failing unit tests
65+
or lowering the code coverage beneath the desired threshold) should not be
66+
pull-requested.
5167

5268
### use the demo script
5369

scripts/run_tests

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ fi
3232
# https://marketplace.visualstudio.com/items?itemName=markis.code-coverage
3333
generate_lcov() {
3434
mkdir -p coverage
35+
# generate coverage report in lcov and HTML format
3536
pdm run coverage-lcov --output_file_path=coverage/lcov.info
37+
pdm run coverage html
3638
}
39+
3740
trap generate_lcov EXIT
41+
pdm run pytest --cov=feeph.i2c --cov-report=term-missing --no-header --quiet tests/
3842

39-
pdm run pytest --cov=feeph.i2c --cov-report= tests/
43+
tox
4044

4145
echo "----------------------------------------------------------------------"
4246
echo "If you reached this far you passed. Congratulations!"

tox.ini

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ requires =
2828
env_list =
2929
lint
3030
type
31-
coverage_clean
3231
py{310,311,312}
33-
coverage_report
3432

3533
; pytest & coverage
3634
; https://pytest-cov.readthedocs.io/en/latest/tox.html
@@ -70,28 +68,14 @@ commands =
7068

7169
[testenv]
7270
description = install pytest in a virtual environment and invoke it on the tests folder
73-
depends =
74-
{py310,py311,312}: coverage_clean
75-
coverage_report: py310,py311,312
7671
set_env =
7772
VIRTUALENV_DISCOVERY = pyenv
7873
deps =
7974
--global-option="$(python-config --includes)" -r requirements.txt
8075
--global-option="$(python-config --includes)" -r requirements-dev.txt
81-
# generate a coverage report but do not mesurements and do not fail
82-
# (we will combine all measurements into a single report later on)
76+
# do not generate a coverage report from tox
77+
# if we would the files would be relative to the tox virtual environments
78+
# and prefixed with '.tox/py*/lib/python*/site-packages/' - which makes
79+
# them interesting to look at but useless for consumption by other tools
8380
commands =
84-
pytest --cov=feeph.i2c --cov-append --cov-report= --cov-fail-under=0 {posargs: tests/}
85-
86-
[testenv:coverage_clean]
87-
deps = coverage
88-
skip_install = true
89-
commands =
90-
coverage erase
91-
92-
[testenv:coverage_report]
93-
deps = coverage
94-
skip_install = true
95-
commands =
96-
coverage report --show-missing
97-
coverage html
81+
pytest --no-cov {posargs: tests/}

0 commit comments

Comments
 (0)