From ca8c5b4daf539c6348962e7e7928524ae9302c15 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 19 Nov 2017 09:34:30 +0000 Subject: [PATCH] Collect code coverage. --- .gitignore | 2 ++ Cargo.toml | 4 ++++ coverage.sh | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100755 coverage.sh 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