Skip to content

Commit

Permalink
First attempt at change to using cargo-llvm-cov for test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gsleap committed Jan 20, 2022
1 parent 3f2467b commit 9bd084b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install nightly toolchain
- name: Install nightly toolchain pinned at 2022-01-14
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2022-01-14
override: true
components: llvm-tools-preview

- name: Install cargo-llvm-cov
run: rustup run nightly-2022-01-14 cargo install cargo-llvm-cov

- name: Build cfitsio
run: |
Expand All @@ -38,28 +41,17 @@ jobs:
sudo ldconfig
cd ..
- name: Install OS and Cargo Packages
- name: Install OS packages
run: |
sudo apt-get update
sudo apt-get install -y lcov clang curl zip unzip libssl-dev jq
cargo update
cargo install --force cargo-make cargo-binutils grcov
sudo apt-get install -y lcov clang curl zip unzip libssl-dev jq
env:
DEBIAN_FRONTEND: noninteractive

- name: Generate test lcov coverage into coverage/ dir
env:
LD_LIBRARY_PATH: /usr/local/lib/
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off"
RUSTDOCFLAGS: "-Cpanic=abort"
LLVM_PROFILE_FILE: json5format-%m.profraw
- name: Generate test lcov coverage into coverage/ dir
run: |
mkdir -p coverage
cargo build
cargo test
zip -0 ccov.zip `find . \( -name "mwalib*.gc*" \) -print`
grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" --excl-br-line "^.*((debug_)?assert(_eq|_ne|_abs_diff_(eq|ne))?!|#\[derive\()" -o coverage/coverage.lcov
rustup run nightly-2022-01-14 cargo llvm-cov --lib --ignore-filename-regex="test.rs" --lcov --output-path coverage/coverage.lcov
- name: Upload reports to codecov.io
uses: codecov/codecov-action@v1
Expand Down
26 changes: 15 additions & 11 deletions tools/cov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
#
echo This should be run from the mwalib base directory!

export LD_LIBRARY_PATH=/usr/local/lib/
export CARGO_INCREMENTAL=0
#export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off"
export RUSTDOCFLAGS="-Cpanic=abort"
export LLVM_PROFILE_FILE=json5format-%m.profraw
rm -rf target

mkdir -p coverage
rustup run nightly cargo build
rustup run nightly cargo test
zip -0 ccov.zip `find . \( -name "mwalib*.gc*" \) -print`
grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o coverage/coverage.lcov
#
# Setup cargo-llvm-cov
# See: https://github.com/taiki-e/cargo-llvm-cov for more info
#
# Toolchain is pinned due to this issue with nightly >2022-01-14: https://github.com/rust-lang/rust/issues/93054
rustup toolchain install nightly-2022-01-14
rustup component add llvm-tools-preview --toolchain nightly-2022-01-14
rustup run nightly-2022-01-14 cargo install cargo-llvm-cov

# Generate coverage and show summary on the console
# The extra options specified:
# * --lib == only cover the library
# * --ignore-filename-regex="test.rs" == skip tests
rustup run nightly-2022-01-14 cargo llvm-cov --lib --ignore-filename-regex="test.rs"

0 comments on commit 9bd084b

Please sign in to comment.