Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate coverage with Rust nightly #378

Merged
merged 4 commits into from
Jun 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,21 @@ $ cargo +nightly bench --features="unstable"
Code coverage
---

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

```bash
$ ./ci/coverage.sh
$ cargo +nightly install cargo-cov
```
The coverage report will be written to `./target/cov/index.html`

Run cargo-cov and generate a report:

```bash
$ cargo +nightly cov test
$ cargo +nightly cov report --open
```

The coverage report will be written to `./target/cov/report/index.html`


Why coverage? While most see coverage as a code quality metric, we see it primarily as a developer
Expand Down
7 changes: 0 additions & 7 deletions ci/buildkite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ steps:
name: "stable [public]"
timeout_in_minutes: 20
- wait
- command: "ci/coverage.sh"
name: "coverage [public]"
timeout_in_minutes: 20
retry:
automatic:
- exit_status: "*"
limit: 2
- command: "ci/docker-run.sh rustlang/rust:nightly ci/test-nightly.sh"
name: "nightly [public]"
timeout_in_minutes: 20
Expand Down
12 changes: 4 additions & 8 deletions ci/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

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

ci/docker-run.sh evilmachines/rust-cargo-kcov \
bash -exc "\
export RUST_BACKTRACE=1; \
cargo build --verbose; \
cargo kcov --lib --verbose; \
"
cargo cov test
cargo cov report

echo Coverage report:
ls -l target/cov/index.html
ls -l target/cov/report/index.html

if [[ -z "$CODECOV_TOKEN" ]]; then
echo CODECOV_TOKEN undefined
else
bash <(curl -s https://codecov.io/bash)
bash <(curl -s https://codecov.io/bash) -x 'llvm-cov gcov'
fi

exit 0
2 changes: 1 addition & 1 deletion ci/test-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ rustc --version
cargo --version

export RUST_BACKTRACE=1
rustup component add rustfmt-preview
cargo build --verbose --features unstable
cargo test --verbose --features unstable
cargo bench --verbose --features unstable
ci/coverage.sh

exit 0