blob: 0007eebd5b0ea2335f5339846422baea2f5e7f61 (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/usr/bin/env bash
set -e
set -o pipefail
if [ -z ${ENABLE_COVERAGE} ] ; then
echo "ENABLE_COVERAGE environment variable is not set, aborting."
exit 1
fi
function usage() {
echo "Error: LCOV and genhtml are required for generating coverage reports."
if [ `uname -s` = 'Linux' ]; then
echo "On Debian-based distros, you can install them via 'apt-get install lcov'"
elif [ `uname -s` = 'Darwin' ]; then
echo "On OS X, you can install them via 'brew install lcov'"
fi
exit 1
}
command -v lcov >/dev/null 2>&1 || usage
command -v genhtml >/dev/null 2>&1 || usage
# Zero coverage counters
lcov \
--quiet \
--zerocounters \
--directory "build/${HOST_SLUG}/${BUILDTYPE}" \
--output-file "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" \
>/dev/null 2>&1
# Run all unit tests
./scripts/run_tests.sh "build/${HOST_SLUG}/${BUILDTYPE}/test"
# Collect coverage data and save it into coverage.info
echo "Collecting coverage data..."
lcov \
--quiet \
--capture \
--no-external \
--directory "src/mbgl" \
--directory "platform" \
--directory "include/mbgl" \
--directory "build/${HOST_SLUG}/${BUILDTYPE}" \
--base-directory "build/${HOST_SLUG}/${BUILDTYPE}" \
--output-file "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" \
>/dev/null 2>&1
# Generate HTML report based on coverage.info
echo "Generating HTML report..."
genhtml \
--quiet \
--show-details \
--keep-descriptions \
--function-coverage \
--no-branch-coverage \
--title "Mapbox GL Native" \
--num-spaces 4 \
--sort \
--demangle-cpp \
--prefix $(pwd -P) \
--output-directory "build/${HOST_SLUG}/${BUILDTYPE}/coverage" \
"build/${HOST_SLUG}/${BUILDTYPE}/coverage.info" \
>/dev/null 2>&1
echo "Coverage report is now available in build/${HOST_SLUG}/${BUILDTYPE}/coverage/index.html"
|