2019-06-25 06:35:33 -07:00
|
|
|
#!/bin/sh
|
|
|
|
# Collect and submit coverage reports.
|
|
|
|
#
|
|
|
|
# Args:
|
|
|
|
# $1: Flag(s) for codecov, separated by comma.
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
# Change to grandparent dir (POSIXly).
|
|
|
|
CDPATH='' cd -P -- "$(dirname -- "$0")/../.." || exit
|
|
|
|
|
|
|
|
echo "=== running submit_coverage in $PWD: $* ==="
|
|
|
|
"$GCOV" --version
|
|
|
|
|
|
|
|
# Download/install codecov-bash and gcovr once.
|
|
|
|
codecov_sh="${TEMP:-/tmp}/codecov.bash"
|
|
|
|
if ! [ -f "$codecov_sh" ]; then
|
|
|
|
curl --retry 5 --silent --fail -o "$codecov_sh" https://codecov.io/bash
|
|
|
|
chmod +x "$codecov_sh"
|
|
|
|
|
|
|
|
python3 -m pip install --quiet --user gcovr
|
|
|
|
fi
|
|
|
|
|
2019-07-24 16:11:17 -07:00
|
|
|
(
|
|
|
|
cd build
|
|
|
|
python3 -m gcovr --branches --exclude-unreachable-branches --print-summary -j 2 --exclude '.*/auto/.*' --root .. --delete -o ../coverage.xml --xml
|
|
|
|
)
|
2019-06-25 06:35:33 -07:00
|
|
|
|
|
|
|
# Upload to codecov.
|
|
|
|
# -X gcov: disable gcov, done manually above.
|
2019-07-07 12:09:37 -07:00
|
|
|
# -X fix: disable fixing of reports (not necessary, rather slow)
|
2019-06-25 06:35:33 -07:00
|
|
|
# -Z: exit non-zero on failure
|
|
|
|
# -F: flag(s)
|
|
|
|
# NOTE: ignoring flags for now, since this causes timeouts on codecov.io then,
|
|
|
|
# which they know about for about a year already...
|
|
|
|
# Flags must match pattern ^[\w\,]+$ ("," as separator).
|
|
|
|
codecov_flags="$(uname -s),${1}"
|
|
|
|
codecov_flags=$(echo "$codecov_flags" | sed 's/[^,_a-zA-Z0-9]/_/g')
|
2019-07-07 12:09:37 -07:00
|
|
|
if ! "$codecov_sh" -f coverage.xml -X gcov -X fix -Z -F "${codecov_flags}"; then
|
2019-06-25 06:35:33 -07:00
|
|
|
echo "codecov upload failed."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cleanup always, especially collected data.
|
|
|
|
find . \( -name '*.gcov' -o -name '*.gcda' \) -ls -delete | wc -l
|
|
|
|
rm -f coverage.xml
|
2019-10-04 07:09:42 -07:00
|
|
|
|
|
|
|
# Upload Lua coverage (generated manually on AppVeyor/Windows).
|
|
|
|
if [ "$USE_LUACOV" = 1 ] && [ "$1" != "oldtest" ]; then
|
2019-10-06 15:44:54 -07:00
|
|
|
if [ -x "${DEPS_BUILD_DIR}/usr/bin/luacov" ]; then
|
|
|
|
"${DEPS_BUILD_DIR}/usr/bin/luacov"
|
|
|
|
fi
|
2019-10-04 07:09:42 -07:00
|
|
|
if ! "$codecov_sh" -f luacov.report.out -X gcov -X fix -Z -F "lua,${codecov_flags}"; then
|
|
|
|
echo "codecov upload failed."
|
|
|
|
fi
|
|
|
|
rm luacov.stats.out
|
|
|
|
fi
|