summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-shaders.py2
-rwxr-xr-xscripts/collect-coverage.sh66
-rwxr-xr-xscripts/coveralls.sh37
-rw-r--r--scripts/main.mk14
4 files changed, 115 insertions, 4 deletions
diff --git a/scripts/build-shaders.py b/scripts/build-shaders.py
index 226c1a2ecc..4cfb3cb384 100755
--- a/scripts/build-shaders.py
+++ b/scripts/build-shaders.py
@@ -23,7 +23,7 @@ content = """// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
#ifndef MBGL_SHADER_{NAME}_{TYPE}
#define MBGL_SHADER_{NAME}_{TYPE}
-#include <mbgl/platform/gl.hpp>
+#include <mbgl/gl/gl.hpp>
namespace mbgl {{
namespace shaders {{
diff --git a/scripts/collect-coverage.sh b/scripts/collect-coverage.sh
new file mode 100755
index 0000000000..0007eebd5b
--- /dev/null
+++ b/scripts/collect-coverage.sh
@@ -0,0 +1,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"
diff --git a/scripts/coveralls.sh b/scripts/coveralls.sh
new file mode 100755
index 0000000000..79e398dc1f
--- /dev/null
+++ b/scripts/coveralls.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -e
+set -o pipefail
+
+PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason"
+
+mapbox_time "install_lcov" \
+mason install lcov 1.12
+
+LCOV="`mason prefix lcov 1.12`/usr/bin/lcov"
+
+mapbox_time "check_mason_lcov" \
+command -v $LCOV > /dev/null 2>&1 || exit 1
+
+mapbox_time "remove_coverage_info" \
+rm -f "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info"
+
+# Run all unit tests
+./scripts/run_tests.sh "build/${HOST_SLUG}/${BUILDTYPE}/test"
+
+# Collect coverage data and save it into coverage.info
+mapbox_time "lcov_capture" \
+$LCOV \
+ --quiet \
+ --capture \
+ --no-external \
+ --gcov-tool "gcov-4.9" \
+ --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"
+
+mapbox_time "coveralls_upload" \
+coveralls-lcov "build/${HOST_SLUG}/${BUILDTYPE}/coverage.info"
diff --git a/scripts/main.mk b/scripts/main.mk
index b2ba014984..0891734543 100644
--- a/scripts/main.mk
+++ b/scripts/main.mk
@@ -53,9 +53,9 @@ SUBMODULES += platform/ios/vendor/SMCalloutView/SMCalloutView.h
platform/ios/vendor/SMCalloutView/SMCalloutView.h:
./scripts/flock.py .git/Submodule.lock git submodule update --init platform/ios/vendor/SMCalloutView
-SUBMODULES += test/ios/KIF/KIF.xcodeproj
-test/ios/KIF/KIF.xcodeproj:
- ./scripts/flock.py .git/Submodule.lock git submodule update --init test/ios/KIF
+SUBMODULES += platform/ios/test/KIF/KIF.xcodeproj
+platform/ios/test/KIF/KIF.xcodeproj:
+ ./scripts/flock.py .git/Submodule.lock git submodule update --init platform/ios/test/KIF
endif
endif
@@ -78,6 +78,8 @@ GYP_FLAGS += -Dasset_lib=$(ASSET)
GYP_FLAGS += -Dheadless_lib=$(HEADLESS)
GYP_FLAGS += -Dtest=$(BUILD_TEST)
GYP_FLAGS += -Drender=$(BUILD_RENDER)
+GYP_FLAGS += -Doffline=$(BUILD_OFFLINE)
+GYP_FLAGS += -Dcoverage=$(ENABLE_COVERAGE)
GYP_FLAGS += -Dcxx_host=$(CXX_HOST)
GYP_FLAGS += --depth=.
GYP_FLAGS += -Goutput_dir=.
@@ -165,6 +167,12 @@ tidy: Ninja/compdb
test-%: Makefile/test
./scripts/run_tests.sh "build/$(HOST_SLUG)/$(BUILDTYPE)/test" --gtest_filter=$*
+check: Makefile/test
+ ./scripts/collect-coverage.sh
+
+coveralls: Makefile/test
+ ./scripts/coveralls.sh
+
#### Helper targets ############################################################
.PHONY: print-env