[tests] Use ENABLE_COVERAGE=1 envvar to enable coverage
This detaches coverage data collection from typical debug build.
This commit is contained in:
2
Makefile
2
Makefile
@@ -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
|
||||
|
||||
@@ -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' ],
|
||||
|
||||
@@ -51,7 +51,11 @@
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [ '--coverage' ],
|
||||
'conditions': [
|
||||
['enable_coverage=="1"', {
|
||||
'OTHER_LDFLAGS': [ '--coverage' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -129,7 +129,11 @@
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [ '--coverage' ],
|
||||
'conditions': [
|
||||
['enable_coverage=="1"', {
|
||||
'OTHER_LDFLAGS': [ '--coverage' ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user