mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-18 13:24:38 +03:00
feat(coverage): Reduce coverage false-negatives using grcov
Previously, we would report some tag style macros such as `#[repr(packed)]` as being uncovered. We are now also including doctests in our coverage reports. Finally, a new script `coverage_report.sh` makes coverage checking easier.
This commit is contained in:
10
.github/workflows/qc.yaml
vendored
10
.github/workflows/qc.yaml
vendored
@@ -194,19 +194,17 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
- run: rustup default nightly
|
||||||
- run: rustup component add llvm-tools-preview
|
- run: rustup component add llvm-tools-preview
|
||||||
- run: |
|
- run: |
|
||||||
cargo install cargo-llvm-cov || true
|
cargo install cargo-llvm-cov || true
|
||||||
cargo llvm-cov \
|
cargo install grcov || true
|
||||||
--workspace\
|
./coverage_report.sh
|
||||||
--all-features \
|
|
||||||
--lcov \
|
|
||||||
--output-path coverage.lcov
|
|
||||||
# If using tarapulin
|
# If using tarapulin
|
||||||
#- run: cargo install cargo-tarpaulin
|
#- run: cargo install cargo-tarpaulin
|
||||||
#- run: cargo tarpaulin --out Xml
|
#- run: cargo tarpaulin --out Xml
|
||||||
- name: Upload coverage reports to Codecov
|
- name: Upload coverage reports to Codecov
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
files: ./coverage.lcov
|
files: ./target/grcov/lcov
|
||||||
verbose: true
|
verbose: true
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ RUST_MIN_STACK=8388608 cargo test --workspace --all-features
|
|||||||
Keep in mind that many of Rosenpass' tests are doctests, so to get an accurate read on our code coverage, you have to include doctests:
|
Keep in mind that many of Rosenpass' tests are doctests, so to get an accurate read on our code coverage, you have to include doctests:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo llvm-cov --all-features --workspace --doctests --html --open
|
./coverage_report.sh
|
||||||
```
|
```
|
||||||
|
|||||||
44
coverage_report.sh
Executable file
44
coverage_report.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
set -e -o pipefail
|
||||||
|
|
||||||
|
OUTPUT_DIR="target/grcov"
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo >&2 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
exc() {
|
||||||
|
echo '$' "$@"
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
exc cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
local open="0"
|
||||||
|
if [[ "$1" == "--open" ]]; then
|
||||||
|
open="1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exc cargo llvm-cov --all-features --workspace --doctests
|
||||||
|
|
||||||
|
exc rm -rf "${OUTPUT_DIR}"
|
||||||
|
exc mkdir -p "${OUTPUT_DIR}"
|
||||||
|
exc grcov target/llvm-cov-target/ --llvm -s . --branch \
|
||||||
|
--binary-path ./target/llvm-cov-target/debug/deps \
|
||||||
|
--ignore-not-existing --ignore '../*' --ignore "/*" \
|
||||||
|
--excl-line '^\s*#\[(derive|repr)\(' \
|
||||||
|
-t lcov,html,markdown -o "${OUTPUT_DIR}"
|
||||||
|
|
||||||
|
if (( "${open}" == 1 )); then
|
||||||
|
xdg-open "${PWD}/${OUTPUT_DIR}/html/index.html"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log ""
|
||||||
|
log "Generated reports in \"${PWD}/${OUTPUT_DIR}\"."
|
||||||
|
log "Open \"${PWD}/${OUTPUT_DIR}/html/index.html\" to view HTML report."
|
||||||
|
log ""
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -121,6 +121,7 @@
|
|||||||
proverif-patched
|
proverif-patched
|
||||||
inputs.fenix.packages.${system}.complete.toolchain
|
inputs.fenix.packages.${system}.complete.toolchain
|
||||||
pkgs.cargo-llvm-cov
|
pkgs.cargo-llvm-cov
|
||||||
|
pkgs.grcov
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
devShells.coverage = pkgs.mkShell {
|
devShells.coverage = pkgs.mkShell {
|
||||||
@@ -128,6 +129,7 @@
|
|||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
inputs.fenix.packages.${system}.complete.toolchain
|
inputs.fenix.packages.${system}.complete.toolchain
|
||||||
pkgs.cargo-llvm-cov
|
pkgs.cargo-llvm-cov
|
||||||
|
pkgs.grcov
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user