From 7f53ea3bf3065200235bb7eff92316359296627b Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Mon, 18 Jun 2018 16:36:37 -0700 Subject: [PATCH] Generate coverage with Rust nightly Fixes #177 Thanks @marco-c! --- README.md | 15 ++++++++++++--- ci/buildkite.yml | 7 ------- ci/coverage.sh | 11 ++++------- ci/test-nightly.sh | 1 + 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8c0b10a4a..555577616 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ci/buildkite.yml b/ci/buildkite.yml index f95af7799..d6cc061cf 100644 --- a/ci/buildkite.yml +++ b/ci/buildkite.yml @@ -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 diff --git a/ci/coverage.sh b/ci/coverage.sh index fc6098fc3..719efd82f 100755 --- a/ci/coverage.sh +++ b/ci/coverage.sh @@ -2,15 +2,12 @@ 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 install cargo-cov +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 diff --git a/ci/test-nightly.sh b/ci/test-nightly.sh index a0ae0102e..a33ba3f77 100755 --- a/ci/test-nightly.sh +++ b/ci/test-nightly.sh @@ -10,5 +10,6 @@ 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