Skip to content

Commit bec7613

Browse files
committed
test: update 'scripts/run_tests' to generate coverage/lcov.info
1 parent af706d0 commit bec7613

5 files changed

Lines changed: 62 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ coverage.xml
5050
.hypothesis/
5151
.pytest_cache/
5252
cover/
53+
coverage/
5354
tests/coverage_report/
5455

5556
# Translations

pdm.lock

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ source-includes = ["tests/"]
9797
dev = [
9898
]
9999
tools = [
100-
"autopep8 ~= 2.2",
101-
"copier ~= 9.3",
102-
"flake8 ~= 7.0",
103-
"mypy ~= 1.10",
104-
"pylint ~= 3.2",
105-
"pytest-cov ~= 5.0",
106-
"pytest-sugar ~= 1.0",
100+
"autopep8 ~= 2.2",
101+
"copier ~= 9.3",
102+
"coverage-lcov ~= 0.3",
103+
"flake8 ~= 7.0",
104+
"mypy ~= 1.10",
105+
"pylint ~= 3.2",
106+
"pytest-cov ~= 5.0",
107+
"pytest-sugar ~= 1.0",
107108
]
108109

109110
# during development: fetch all packages in our namespace from TestPyPI

requirements-dev.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ astroid==3.2.4 \
1010
autopep8==2.3.1 \
1111
--hash=sha256:8d6c87eba648fdcfc83e29b788910b8643171c395d9c4bcf115ece035b9c9dda \
1212
--hash=sha256:a203fe0fcad7939987422140ab17a930f684763bf7335bdb6709991dd7ef6c2d
13+
click==8.1.7 \
14+
--hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \
15+
--hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de
1316
colorama==0.4.6 \
1417
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
1518
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
@@ -49,6 +52,9 @@ coverage==7.6.1 \
4952
--hash=sha256:f5796e664fe802da4f57a168c85359a8fbf3eab5e55cd4e4569fbacecc903959 \
5053
--hash=sha256:fc5a77d0c516700ebad189b587de289a20a78324bc54baee03dd486f0855d234 \
5154
--hash=sha256:fd21f6ae3f08b41004dfb433fa895d858f3f5979e7762d052b12aef444e29afc
55+
coverage-lcov==0.3.0 \
56+
--hash=sha256:0b352da0c72eacd555de2e10fa75ec165b8849ab6827218abc3ef6be2ec861f6 \
57+
--hash=sha256:23ae34a535f1ed3fa4cdf9682f6c1fe1a40aa98c94aa05614512dbf2da82e749
5258
coverage[toml]==7.6.1 \
5359
--hash=sha256:07e2ca0ad381b91350c0ed49d52699b625aab2b44b65e1b4e02fa9df0e92ad2d \
5460
--hash=sha256:0c0420b573964c760df9e9e86d1a9a622d0d27f417e1a949a8a66dd7bcee7bc6 \

scripts/run_tests

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ if [[ -n $FILES ]] ; then
2323
pdm run mypy $FILES
2424
fi
2525

26+
# Generate a coverage report in lcov format even if pytest fails due to
27+
# lacking coverage. The report can then be used by an IDE to indicate
28+
# coverage directly in your editor window. Special care must be taken
29+
# when working on code that isn't covered by unit tests.
30+
#
31+
# recommended extension for VS Code:
32+
# https://marketplace.visualstudio.com/items?itemName=markis.code-coverage
33+
generate_lcov() {
34+
mkdir -p coverage
35+
pdm run coverage-lcov --output_file_path=coverage/lcov.info
36+
}
37+
trap generate_lcov EXIT
38+
39+
pdm run pytest --cov=feeph.i2c --cov-report= tests/
40+
2641
echo "----------------------------------------------------------------------"
2742
echo "If you reached this far you passed. Congratulations!"
2843
echo "----------------------------------------------------------------------"

0 commit comments

Comments
 (0)