#!/bin/sh coveralls= [ -n "$TRAVIS_JOB_ID" ] && coveralls="--coveralls-id=${TRAVIS_JOB_ID}" exclude="--exclude-pattern=.cargo,/usr/lib" PROJECT=woodpecker OUTPUT=target/cov/${PROJECT} POUTPUT1=${OUTPUT}-1 POUTPUT2=${OUTPUT}-2 POUTPUT="${POUTPUT1} ${POUTPUT2}" die() { echo $* exit 1 } findexe() { EXE=$(find target/debug -type f -executable -name "${PROJECT}-*" -printf '%p\n' | sort -r | head -n 1) [ -z "$EXE" ] && die "Failed to find test file" } kcov=${HOME}/apps/kcov/bin/kcov if [ ! -e $kcov ]; then kcov=kcov fi ${kcov} --version >/dev/null 2>&1 || die "kcov is not installed" rm -rf $OUTPUT $POUTPUT mkdir -p $OUTPUT $POUTPUT cargo test --no-run || die findexe ${kcov} $exclude --verify $POUTPUT1 $EXE || die cargo test --no-run --features test-thread-log || die findexe ${kcov} $exclude --verify $POUTPUT2 $EXE || die ${kcov} $coveralls --merge $OUTPUT $POUTPUT || die echo "Check out the coverage via file://$(pwd)/${OUTPUT}/index.html"