Skip to content

Commit

Permalink
build: fix coverage conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorgner committed Feb 29, 2020
1 parent 4ccf8aa commit eee66b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ install:
- sudo apt-get install cmake

script:
- /usr/bin/cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=YES -DRUN_TESTS_AFTER_BUILD=YES -DENABLE_CODE_COVERAGE=YES -DPRINT_COVERAGE_REPORT=YES ..
- /usr/bin/cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=YES -DRUN_TESTS_AFTER_BUILD=YES -DENABLE_CODE_COVERAGE=YES -DPRINT_COVERAGE_REPORT=YES
- /usr/bin/cmake --build build --target all --parallel $(nproc)
24 changes: 14 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ if(BUILD_TESTING)
)
endif()

if(GENERATE_COVERAGE_REPORT AND RUN_TESTS_AFTER_BUILD)
if(ENABLE_CODE_COVERAGE AND RUN_TESTS_AFTER_BUILD)
add_custom_command(TARGET "${PROJECT_NAME}_tests"
POST_BUILD
BYPRODUCTS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.coverage.info"
Expand All @@ -140,16 +140,20 @@ if(BUILD_TESTING)
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Capturing code coverage data"
)
add_custom_command(TARGET "${PROJECT_NAME}_tests"
POST_BUILD
COMMAND "${LCOV_EXE}"
ARGS
"--list"
"${PROJECT_NAME}.coverage.info"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Printing code coverage report"
)

if(PRINT_COVERAGE_REPORT)
add_custom_command(TARGET "${PROJECT_NAME}_tests"
POST_BUILD
COMMAND "${LCOV_EXE}"
ARGS
"--list"
"${PROJECT_NAME}.coverage.info"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Printing code coverage report"
)
endif()

if(GENERATE_COVERAGE_REPORT)
add_custom_command(TARGET "${PROJECT_NAME}_tests"
POST_BUILD
BYPRODUCTS "${PROJECT_BINARY_DIR}/coverage-report/index.html"
Expand Down

0 comments on commit eee66b5

Please sign in to comment.