build: make DO_COVERAGE a CMake variable

Travis: remove CXXFLAGS (not used), LDFLAGS (typo, not used)

Closes https://github.com/awesomeWM/awesome/pull/2001.
This commit is contained in:
Daniel Hahler 2017-08-16 00:48:42 +02:00
parent 69d06f7e3a
commit 8923df4a5f
3 changed files with 9 additions and 13 deletions

View File

@ -105,8 +105,7 @@ install:
fi
# Install dependencies for code coverage testing.
- if [ "$DO_COVERAGE" = "" ]; then export DO_COVERAGE=0; fi
- if [ "$DO_COVERAGE" != "0" ]; then sudo luarocks install cluacov; fi
- if [ -n "$DO_COVERAGE" ]; then sudo luarocks install cluacov; fi
- if [ "$DO_COVERAGE" = "coveralls" ]; then sudo luarocks install luacov-coveralls; fi
# Determine custom version.
@ -156,13 +155,7 @@ install:
return 0
}
script:
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true"
- |
if [ "$DO_COVERAGE" = "codecov" ]; then
export CXXFLAGS="-fprofile-arcs -ftest-coverage"
export CFLAGS="-fprofile-arcs -ftest-coverage"
export LDFLAFS="-fprofile-arcs -ftest-coverage"
fi
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true -D DO_COVERAGE=$DO_COVERAGE"
- |
if [ "$EMPTY_THEME_WHILE_LOADING" = 1 ]; then
# Break beautiful so that trying to access the theme before beautiful.init() causes an error
@ -189,7 +182,7 @@ script:
- |
set -ex
if [ "$TRAVIS_TEST_RESULT" = 0 ]; then
if [ "$DO_COVERAGE" != "0" ]; then
if [ -n "$DO_COVERAGE" ]; then
travis_fold_start "DO_COVERAGE"
# Run tests/examples explicitly.
@ -237,7 +230,7 @@ script:
echo "Testing commit $commit"
git checkout "$commit"
git --no-pager show --stat
if ! DO_COVERAGE=0 make all check; then
if ! make all check CMAKE_ARGS+="-D DO_COVERAGE=0"; then
failed="$failed $commit"
fi
travis_fold_end

View File

@ -10,8 +10,10 @@ option(WITH_DBUS "build with D-BUS" ON)
option(GENERATE_MANPAGES "generate manpages" ON)
option(COMPRESS_MANPAGES "compress manpages" ON)
option(GENERATE_DOC "generate API documentation" ON)
if (GENERATE_DOC AND ENV{DO_COVERAGE})
option(DO_COVERAGE "build with coverage" OFF)
if (GENERATE_DOC AND DO_COVERAGE)
message(STATUS "Not generating API documentation with DO_COVERAGE")
set(GENERATE_DOC OFF)
endif()
# {{{ Endianness
@ -332,6 +334,7 @@ if(DO_COVERAGE)
${BUILD_DIR}/${file}
COPYONLY)
endforeach()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
else()
foreach(file ${AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES})
configure_file(${SOURCE_DIR}/${file}

View File

@ -29,7 +29,7 @@ else()
set(TOP_SOURCE_DIR ${CMAKE_SOURCE_DIR})
endif()
if (DEFINED ENV{DO_COVERAGE} AND NOT $ENV{DO_COVERAGE} STREQUAL "0")
if (DO_COVERAGE)
execute_process(
COMMAND lua -e "require('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')"
RESULT_VARIABLE TEST_RESULT