diff --git a/.gitignore b/.gitignore index a9d37c5..2cbb12a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ target Cargo.lock +*.gcno +*.gcda diff --git a/Cargo.toml b/Cargo.toml index 70e0dbc..ac4bc50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,7 @@ alloc = [] default = ["std"] # Unstable features map = [] + +[profile.test] +opt-level = 1 +codegen-units = 1 diff --git a/coverage.sh b/coverage.sh new file mode 100755 index 0000000..7a84b2f --- /dev/null +++ b/coverage.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +cargo rustc -- --test -C link-dead-code -Z profile -Z no-landing-pads + +LCOVOPTS=( + --gcov-tool llvm-gcov + --rc lcov_branch_coverage=1 + --rc lcov_excl_line=assert +) +lcov "${LCOVOPTS[@]}" --capture --directory . --base-directory . \ + -o target/coverage/raw.lcov +lcov "${LCOVOPTS[@]}" --extract target/coverage/raw.lcov "$(pwd)/*" \ + -o target/coverage/raw_crate.lcov + +genhtml --branch-coverage --demangle-cpp --legend \ + -o target/coverage/ \ + target/coverage/raw_crate.lcov