Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 07bd8ba

Browse files
committed
Generate coverage with Rust nightly
Fixes #177 Thanks @marco-c!
1 parent b2accd1 commit 07bd8ba

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,21 @@ $ cargo +nightly bench --features="unstable"
234234
Code coverage
235235
---
236236

237-
To generate code coverage statistics, run kcov via Docker:
237+
To generate code coverage statistics, install cargo-cov. Note: the tool currently only works
238+
in Rust nightly.
238239

239240
```bash
240-
$ ./ci/coverage.sh
241+
$ cargo +nightly install cargo-cov
241242
```
242-
The coverage report will be written to `./target/cov/index.html`
243+
244+
Run cargo-cov and generate a report:
245+
246+
```bash
247+
$ cargo +nightly cov test
248+
$ cargo +nightly cov report --open
249+
```
250+
251+
The coverage report will be written to `./target/cov/report/index.html`
243252

244253

245254
Why coverage? While most see coverage as a code quality metric, we see it primarily as a developer

ci/buildkite.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ steps:
33
name: "stable [public]"
44
timeout_in_minutes: 20
55
- wait
6-
- command: "ci/coverage.sh"
7-
name: "coverage [public]"
8-
timeout_in_minutes: 20
9-
retry:
10-
automatic:
11-
- exit_status: "*"
12-
limit: 2
136
- command: "ci/docker-run.sh rustlang/rust:nightly ci/test-nightly.sh"
147
name: "nightly [public]"
158
timeout_in_minutes: 20

ci/coverage.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
cd "$(dirname "$0")/.."
44

5-
ci/docker-run.sh evilmachines/rust-cargo-kcov \
6-
bash -exc "\
7-
export RUST_BACKTRACE=1; \
8-
cargo build --verbose; \
9-
cargo kcov --lib --verbose; \
10-
"
5+
cargo install cargo-cov
6+
cargo cov test
7+
cargo cov report
118

129
echo Coverage report:
13-
ls -l target/cov/index.html
10+
ls -l target/cov/report/index.html
1411

1512
if [[ -z "$CODECOV_TOKEN" ]]; then
1613
echo CODECOV_TOKEN undefined

ci/test-nightly.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ rustup component add rustfmt-preview
1010
cargo build --verbose --features unstable
1111
cargo test --verbose --features unstable
1212
cargo bench --verbose --features unstable
13+
ci/coverage.sh
1314

1415
exit 0

0 commit comments

Comments
 (0)