forked from RGB-Tools/rgb-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch coverage from tarpaulin to llvm-cov
- Loading branch information
Showing
1 changed file
with
59 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,61 @@ | ||
#!/bin/bash -e | ||
# | ||
# script to run projects tests and report code coverage | ||
# | ||
# uses tarpaulin (https://crates.io/crates/cargo-tarpaulin) | ||
# | ||
# other coverage solutions exist but all require rust nightly and the project | ||
# does not build with nightly at the moment | ||
|
||
# install tarpaulin if missing | ||
cargo tarpaulin --help >/dev/null 2>&1 || cargo install cargo-tarpaulin | ||
|
||
# run tests | ||
# --skip-clean to avoid re-building everything each time | ||
cargo tarpaulin \ | ||
--count \ | ||
--line \ | ||
--locked \ | ||
--skip-clean \ | ||
--ignore-tests \ | ||
--exclude-files rgb-lib-ffi/ \ | ||
--exclude-files tests/ \ | ||
--exclude-files src/wallet/test/ \ | ||
--out Html \ | ||
-- \ | ||
--test-threads=1 | ||
|
||
# open the html test report in the default browser | ||
xdg-open tarpaulin-report.html | ||
# script to run project tests and report code coverage | ||
# uses llvm-cov (https://github.com/taiki-e/cargo-llvm-cov) | ||
|
||
LLVM_COV_OPTS="" | ||
CARGO_TEST_OPTS="" | ||
|
||
_die() { | ||
echo "err $*" | ||
exit 1 | ||
} | ||
|
||
_tit() { | ||
echo | ||
echo "========================================" | ||
echo "$@" | ||
echo "========================================" | ||
} | ||
|
||
help() { | ||
echo "$NAME [-h|--help] [-t|--test] [--no-clean]" | ||
echo "" | ||
echo "options:" | ||
echo " -h --help show this help message" | ||
echo " -t --test only run these test(s)" | ||
echo " --no-clean don't cleanup before the run" | ||
} | ||
|
||
# cmdline arguments | ||
while [ -n "$1" ]; do | ||
case $1 in | ||
-h|--help) | ||
help | ||
exit 0 | ||
;; | ||
-t|--test) | ||
CARGO_TEST_OPTS="-- $2" | ||
shift | ||
;; | ||
--no-clean) | ||
LLVM_COV_OPTS="$1" | ||
;; | ||
*) | ||
help | ||
_die "unsupported argument \"$1\"" | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
_tit "installing requirements" | ||
rustup component add llvm-tools-preview | ||
cargo install cargo-llvm-cov | ||
|
||
_tit "generating coverage report" | ||
# shellcheck disable=2086 | ||
cargo llvm-cov --html $LLVM_COV_OPTS $CARGO_TEST_OPTS | ||
|
||
## show html report location | ||
echo "generated html report: target/llvm-cov/html/index.html" |