diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-02-19 15:31:29 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-02-19 17:40:30 +0200 |
commit | 6792d789521a104f78a9a702672672387831d78c (patch) | |
tree | e068269e371e6847f53739105aa44d80443a09e7 | |
parent | 6a2d910ccdb8a2521e1dbe4617e5bbdddb6cc4eb (diff) | |
download | qtlocation-mapboxgl-6792d789521a104f78a9a702672672387831d78c.tar.gz |
[tests] Use ENABLE_COVERAGE=1 envvar to enable coverage
This detaches coverage data collection from typical debug build.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | gyp/common.gypi | 21 | ||||
-rw-r--r-- | platform/linux/mapboxgl-app.gypi | 6 | ||||
-rwxr-xr-x | scripts/collect-coverage.sh | 5 | ||||
-rw-r--r-- | scripts/main.mk | 5 | ||||
-rw-r--r-- | test/test.gypi | 6 |
6 files changed, 36 insertions, 9 deletions
@@ -118,7 +118,7 @@ xtest: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/test endif .PHONY: check -check: ; $(RUN) BUILDTYPE=Debug check +check: ; $(RUN) BUILDTYPE=Debug ENABLE_COVERAGE=1 check .PHONY: render render: ; $(RUN) Makefile/mbgl-render diff --git a/gyp/common.gypi b/gyp/common.gypi index 685242057b..13565b04e6 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -97,8 +97,12 @@ '-fno-common', '--coverage', ], - 'ldflags': [ - '--coverage', + 'conditions': [ + ['enable_coverage=="1"', { + 'cflags_cc': [ '<@(cflags_cc)', '--coverage' ], + }, { + 'ldflags': [ '--coverage' ], + }], ], 'defines': [ 'DEBUG' ], 'xcode_settings': { @@ -106,10 +110,15 @@ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES', 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES', 'DEAD_CODE_STRIPPING': 'NO', - 'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES', - 'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES', - 'OTHER_CPLUSPLUSFLAGS': [ '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common', '-fprofile-arcs', '-ftest-coverage' ], - } + 'OTHER_CPLUSPLUSFLAGS': [ '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], + 'conditions': [ + ['enable_coverage=="1"', { + 'GCC_INSTRUMENT_PROGRAM_FLOW_ARCS': 'YES', + 'GCC_GENERATE_TEST_COVERAGE_FILES': 'YES', + 'OTHER_CPLUSPLUSFLAGS': [ '<@(OTHER_CPLUSPLUSFLAGS)', '-fprofile-arcs', '-ftest-coverage' ], + }], + ], + }, }, 'Release': { 'cflags_cc': [ '-g', '-O3' ], diff --git a/platform/linux/mapboxgl-app.gypi b/platform/linux/mapboxgl-app.gypi index 4f9c6317c9..19c17f6249 100644 --- a/platform/linux/mapboxgl-app.gypi +++ b/platform/linux/mapboxgl-app.gypi @@ -51,7 +51,11 @@ 'configurations': { 'Debug': { 'xcode_settings': { - 'OTHER_LDFLAGS': [ '--coverage' ], + 'conditions': [ + ['enable_coverage=="1"', { + 'OTHER_LDFLAGS': [ '--coverage' ], + }], + ], }, }, }, diff --git a/scripts/collect-coverage.sh b/scripts/collect-coverage.sh index 65f96a0b2b..0007eebd5b 100755 --- a/scripts/collect-coverage.sh +++ b/scripts/collect-coverage.sh @@ -3,6 +3,11 @@ 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 diff --git a/scripts/main.mk b/scripts/main.mk index b11e9053a0..de49c9967a 100644 --- a/scripts/main.mk +++ b/scripts/main.mk @@ -83,6 +83,11 @@ GYP_FLAGS += -Dcxx_host=$(CXX_HOST) GYP_FLAGS += --depth=. GYP_FLAGS += -Goutput_dir=. GYP_FLAGS += --generator-output=./build/$(HOST_SLUG) +ifeq ($(ENABLE_COVERAGE),1) +GYP_FLAGS += -Denable_coverage=1 +else ifneq ($(ENABLE_COVERAGE),1) +GYP_FLAGS += -Denable_coverage=0 +endif .PHONY: Makefile/__project__ Makefile/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi diff --git a/test/test.gypi b/test/test.gypi index f648657c85..1842a807fb 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -129,7 +129,11 @@ 'configurations': { 'Debug': { 'xcode_settings': { - 'OTHER_LDFLAGS': [ '--coverage' ], + 'conditions': [ + ['enable_coverage=="1"', { + 'OTHER_LDFLAGS': [ '--coverage' ], + }], + ], }, }, }, |