Skip to content

Commit

Permalink
docs: Add lcov / codecov options for nox coverage and update docs (#3825
Browse files Browse the repository at this point in the history
)

* docs: Clarify use of llmv-cov plugin

* Mention first-run

* Update Contributing.md

* Add options

* fix
  • Loading branch information
alxhill committed Feb 23, 2024
1 parent 6a81587 commit 0f92b67
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -22,5 +22,6 @@ pip-wheel-metadata
valgrind-python.supp
*.pyd
lcov.info
coverage.json
netlify_build/
.nox/
9 changes: 7 additions & 2 deletions Contributing.md
Expand Up @@ -177,9 +177,14 @@ Second, there is a Python-based benchmark contained in the `pytests` subdirector

You can view what code is and isn't covered by PyO3's tests. We aim to have 100% coverage - please check coverage and add tests if you notice a lack of coverage!

- First, generate a `lcov.info` file with
- First, ensure the llmv-cov cargo plugin is installed. You may need to run the plugin through cargo once before using it with `nox`.
```shell
nox -s coverage
cargo install cargo-llvm-cov
cargo llvm-cov
```
- Then, generate an `lcov.info` file with
```shell
nox -s coverage -- lcov
```
You can install an IDE plugin to view the coverage. For example, if you use VSCode:
- Add the [coverage-gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) plugin.
Expand Down
12 changes: 10 additions & 2 deletions noxfile.py
Expand Up @@ -61,6 +61,14 @@ def coverage(session: nox.Session) -> None:
session.env.update(_get_coverage_env())
_run_cargo(session, "llvm-cov", "clean", "--workspace")
test(session)

cov_format = "codecov"
output_file = "coverage.json"

if "lcov" in session.posargs:
cov_format = "lcov"
output_file = "lcov.info"

_run_cargo(
session,
"llvm-cov",
Expand All @@ -70,9 +78,9 @@ def coverage(session: nox.Session) -> None:
"--package=pyo3-macros",
"--package=pyo3-ffi",
"report",
"--codecov",
f"--{cov_format}",
"--output-path",
"coverage.json",
output_file,
)


Expand Down

0 comments on commit 0f92b67

Please sign in to comment.