From 8923df4a5f658887c457b4671d20079b4b7bbe03 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 16 Aug 2017 00:48:42 +0200 Subject: [PATCH] build: make DO_COVERAGE a CMake variable Travis: remove CXXFLAGS (not used), LDFLAGS (typo, not used) Closes https://github.com/awesomeWM/awesome/pull/2001. --- .travis.yml | 15 ++++----------- awesomeConfig.cmake | 5 ++++- tests/examples/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a061b86..1d73eb87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index b039a88c..8dc4b06a 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -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} diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index db382089..f67eabbe 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -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