Skip to content

Commit a0281ce

Browse files
clarified README.md
1 parent 64de982 commit a0281ce

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

README.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
# NOTE:
21

3-
This creates a minimum reproducible example for this `cargo-llvm-cov` issue: [warning: N functions have mismatched data](https://github.com/taiki-e/cargo-llvm-cov/issues/329)
2+
> [!NOTE]
3+
> This is fork of [Colin Jermain's original](https://github.com/cjermain/rust-python-coverage) with the following changes:
4+
> - Updated to latest `PyO3`, `maturin`, and `pytest-cov` dependencies
5+
> - Updated the coverage output paths for clarity
6+
> - Added a `run-cov.sh` script that also explains some detail on coverage data generation
7+
> - Added a `nix` devshell for easy setup
48
5-
Trying to keep it reproducible, a nix dev-shell and run-script are provided.
9+
> [!NOTE]
10+
> `cargo-llvm-cov` will generatte this warning when used with [nightly toolchains](https://github.com/taiki-e/cargo-llvm-cov/issues/329)
11+
> `warning: N functions have mismatched data`
12+
> This can be reproduced by checking out the `cargo-llvm-cov-nightly` branch
613
7-
```
8-
nix develop .
9-
./run-cov.sh
10-
```
11-
12-
```console
13-
cargo llvm-cov report --html --open --output-dir .
14-
warning: 1 functions have mismatched data
15-
16-
Finished report saved to ./html
17-
Opening ./html/index.html
18-
19-
```
20-
21-
I recommend the [Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer) if you need nix.
2214

2315
-------
2416
-------
2517

26-
# [Original README.md](https://github.com/cjermain/rust-python-coverage)
27-
2818
# rust-python-coverage
2919
Example PyO3 project with automated test coverage for Rust and Python
3020

@@ -63,8 +53,18 @@ Each area defines a simple function for adding two numbers:
6353
In order to get full test coverage of all of the functions, both the Python
6454
and Rust tests need to be run. We'll show the process step by step.
6555

56+
### Setup: Installing Dependencies
57+
6658
Before getting started, install `cargo-llvm-cov`:
6759

60+
> [!NOTE]
61+
> If you use nix flakes, you can use the provided devshell to install the dependencies
62+
> ```
63+
> nix develop .
64+
> ```
65+
> If you are interested in `nix`, I recommend the [Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer).
66+
67+
6868
```
6969
rustup component add llvm-tools-preview
7070
cargo install cargo-llvm-cov
@@ -80,6 +80,8 @@ source venv/bin/activate
8080
pip install -r requirements.txt
8181
```
8282
83+
### Setup: Preparing `cargo-llvm-cov` environment variables
84+
8385
The Rust tests use `cargo test`. To measure the full Rust coverage from Python
8486
tests, `cargo-llvm-cov` provides a set of environment variables that cause the
8587
Rust binaries to include [instrumentation coverage](https://doc.rust-lang.org/stable/rustc/instrument-coverage.html)
@@ -111,11 +113,11 @@ With these environment variables set up, we are ready to run the coverage
111113
measurements.
112114
113115
```
114-
cargo llvm-cov clean --workspace
116+
cargo llvm-cov clean --workspace -v
115117
cargo test
116118
maturin develop
117-
pytest tests --cov=foobar --cov-report xml
118-
cargo llvm-cov --no-run --lcov --output-path coverage.lcov
119+
pytest tests --cov=foobar --cov-report lcov:python-coverage.lcov
120+
cargo llvm-cov --no-run --lcov --output-path rust-coverage.lcov
119121
```
120122
121123
First the `cargo llvm-cov clean` command removes any previous profiling
@@ -129,3 +131,16 @@ files to CodeCov. [Merging reports](https://docs.codecov.com/docs/merging-report
129131
is an automatic feature of CodeCov, so the final view shows the combined view.
130132
131133
https://codecov.io/gh/cjermain/rust-python-coverage
134+
135+
136+
## Appendix
137+
138+
If you'd like to *save* the html report for the Rust code, you can run the following command:
139+
140+
```console
141+
cargo llvm-cov report --html --open --output-dir .
142+
warning: 1 functions have mismatched data
143+
144+
Finished report saved to ./html
145+
Opening ./html/index.html
146+
```

0 commit comments

Comments
 (0)