blob: 1de0358317af9bd95759f85d84c755ddfb69117e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env bash
#
# Usage:
# ./coverage
#
# Run kcov on the tests, and merge the results.
#
# Environment variables:
# TRAVIS_JOB_ID - id for coveralls, defaults to none
# KCOV - path to kcov, defaults to 'kcov'
[ -n "$TRAVIS_JOB_ID" ] && COVERALLS_ID="--coveralls-id=$TRAVIS_JOB_ID"
[ -z "$KCOV" ] && KCOV=kcov
# Rebuild tests with dead code included, and get a list of the filenames.
export RUSTFLAGS="-C link-dead-code"
TEST_FILES=$(cargo test 2>&1 >/dev/null | awk '/^ Running target\/debug\// { print $2 }')
KCOV_OPTS="--verify --exclude-pattern=/.cargo"
OUT_DIR=target/kcov
for f in $TEST_FILES; do
"$KCOV" $KCOV_OPTS "$OUT_DIR" $f
done
"$KCOV" --merge $KCOV_OPTS $COVERALLS_ID "$OUT_DIR" "$OUT_DIR"
|