Last active
November 28, 2015 01:44
-
-
Save colin-kiegel/e3a1fea04cd3ad8ed06d to your computer and use it in GitHub Desktop.
cargo-kcov
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
#!/bin/bash | |
# original source https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650 | |
# modified version https://gist.github.com/colin-kiegel/e3a1fea04cd3ad8ed06d | |
PKGID="$(cargo pkgid)" | |
[ -z "$PKGID" ] && exit 1 | |
ORIGIN="${PKGID%#*}" | |
ORIGIN="${ORIGIN:7}" | |
PKGNAME="${ORIGIN##*/}" | |
PKGNAMEVER="${PKGID#*#}" | |
echo "cargo pkgid: $PKGID" | |
echo " -> origin: $ORIGIN" | |
echo " -> name: $PKGNAME" | |
echo " -> version: $PKGNAMEVER" | |
shift | |
cargo test --no-run || exit $? | |
EXE=($ORIGIN/target/debug/$PKGNAME-*) | |
if [ ${#EXE[@]} -ne 1 ]; then | |
echo 'Non-unique test file, retrying...' >2 | |
rm -f ${EXE[@]} | |
cargo test --no-run || exit $? | |
fi | |
rm -rf $ORIGIN/target/cov | |
kcov --verify $ORIGIN/target/cov $ORIGIN/target/debug/$PKGNAME-* "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x