Skip to content

Commit 9bd084b

Browse files
committed
First attempt at change to using cargo-llvm-cov for test coverage
1 parent 3f2467b commit 9bd084b

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

.github/workflows/coverage.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ jobs:
1313
- name: Checkout sources
1414
uses: actions/checkout@v2
1515

16-
- name: Install nightly toolchain
16+
- name: Install nightly toolchain pinned at 2022-01-14
1717
uses: actions-rs/toolchain@v1
1818
with:
1919
profile: minimal
20-
toolchain: nightly
20+
toolchain: nightly-2022-01-14
2121
override: true
2222
components: llvm-tools-preview
23+
24+
- name: Install cargo-llvm-cov
25+
run: rustup run nightly-2022-01-14 cargo install cargo-llvm-cov
2326

2427
- name: Build cfitsio
2528
run: |
@@ -38,28 +41,17 @@ jobs:
3841
sudo ldconfig
3942
cd ..
4043
41-
- name: Install OS and Cargo Packages
44+
- name: Install OS packages
4245
run: |
4346
sudo apt-get update
44-
sudo apt-get install -y lcov clang curl zip unzip libssl-dev jq
45-
cargo update
46-
cargo install --force cargo-make cargo-binutils grcov
47+
sudo apt-get install -y lcov clang curl zip unzip libssl-dev jq
4748
env:
4849
DEBIAN_FRONTEND: noninteractive
4950

50-
- name: Generate test lcov coverage into coverage/ dir
51-
env:
52-
LD_LIBRARY_PATH: /usr/local/lib/
53-
CARGO_INCREMENTAL: 0
54-
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off"
55-
RUSTDOCFLAGS: "-Cpanic=abort"
56-
LLVM_PROFILE_FILE: json5format-%m.profraw
51+
- name: Generate test lcov coverage into coverage/ dir
5752
run: |
5853
mkdir -p coverage
59-
cargo build
60-
cargo test
61-
zip -0 ccov.zip `find . \( -name "mwalib*.gc*" \) -print`
62-
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
54+
rustup run nightly-2022-01-14 cargo llvm-cov --lib --ignore-filename-regex="test.rs" --lcov --output-path coverage/coverage.lcov
6355
6456
- name: Upload reports to codecov.io
6557
uses: codecov/codecov-action@v1

tools/cov.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
#
55
echo This should be run from the mwalib base directory!
66

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

14-
mkdir -p coverage
15-
rustup run nightly cargo build
16-
rustup run nightly cargo test
17-
zip -0 ccov.zip `find . \( -name "mwalib*.gc*" \) -print`
18-
grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o coverage/coverage.lcov
9+
#
10+
# Setup cargo-llvm-cov
11+
# See: https://github.com/taiki-e/cargo-llvm-cov for more info
12+
#
13+
# Toolchain is pinned due to this issue with nightly >2022-01-14: https://github.com/rust-lang/rust/issues/93054
14+
rustup toolchain install nightly-2022-01-14
15+
rustup component add llvm-tools-preview --toolchain nightly-2022-01-14
16+
rustup run nightly-2022-01-14 cargo install cargo-llvm-cov
17+
18+
# Generate coverage and show summary on the console
19+
# The extra options specified:
20+
# * --lib == only cover the library
21+
# * --ignore-filename-regex="test.rs" == skip tests
22+
rustup run nightly-2022-01-14 cargo llvm-cov --lib --ignore-filename-regex="test.rs"

0 commit comments

Comments
 (0)