Files
MapLibreParticleLab/scripts/collect-coverage.sh
John Firebaugh f964e40e7e [build] Refactor and simplify build system
* Main gyp files are now standardized as platform/<platform>/platform.gyp.
* Each platform gyp file defines appropriate loop_lib and headless_lib variables.
* Each platform gyp file includes mbgl.gypi, which defines base targets which may be useful to all platforms.
* CI targets are consistent across platforms: `make $(PLATFORM) && make test-$(PLATFORM)`.
* Renamed the "linux" test app to "glfw". It's now built in OS X CI.
* Android build flakiness is fixed.
* iOS CI builds the bench and iosapp targets.
* Mesa version is now in one place.
* CI scripts use bash "strict mode" and correct error handling.
* All build output goes to the build directory.
* Removed vestigial iOS/OS X/Android Travis scripts.
2016-04-07 18:01:02 -07:00

67 lines
1.8 KiB
Bash
Executable File

#!/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/${PLATFORM_SLUG}/${BUILDTYPE}" \
--output-file "build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage.info" \
>/dev/null 2>&1
# Run all unit tests
make 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/${PLATFORM_SLUG}/${BUILDTYPE}" \
--base-directory "build/${PLATFORM_SLUG}/${BUILDTYPE}" \
--output-file "build/${PLATFORM_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/${PLATFORM_SLUG}/${BUILDTYPE}/coverage" \
"build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage.info" \
>/dev/null 2>&1
echo "Coverage report is now available in build/${PLATFORM_SLUG}/${BUILDTYPE}/coverage/index.html"