From 6ab4bb9d54cb51a80e0130fa9417bbe0cc6b25dd Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 1 May 2024 22:22:11 +0200 Subject: [PATCH] add script to create coverage report manually --- flake.nix | 3 ++- scripts/coverage.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 scripts/coverage.sh diff --git a/flake.nix b/flake.nix index 9bb5cc9..e32d029 100644 --- a/flake.nix +++ b/flake.nix @@ -26,9 +26,10 @@ devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell { packages = [ (toolchain.withComponents [ - "cargo" "rustc" "rustfmt" "clippy" + "cargo" "rustc" "rustfmt" "clippy" "llvm-tools" ]) pkgs.mpv + pkgs.grcov ]; RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/"; }); diff --git a/scripts/coverage.sh b/scripts/coverage.sh new file mode 100755 index 0000000..671a8a3 --- /dev/null +++ b/scripts/coverage.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +mkdir -p target/coverage + +echo "Running tests" +RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="target/coverage/%p-%m.profraw" cargo test --all-features --release --no-fail-fast --lib --bins + +echo "Generating coverage report" +grcov \ + --source-dir . \ + --binary-path ./target/release/deps/ \ + --excl-start 'mod test* \{' \ + --ignore 'tests/*' \ + --ignore "*test.rs" \ + --ignore "*tests.rs" \ + --ignore "*github.com*" \ + --ignore "*libcore*" \ + --ignore "*rustc*" \ + --ignore "*liballoc*" \ + --ignore "*cargo*" \ + -t html \ + -o ./target/coverage/html \ + target/coverage/ \ No newline at end of file