mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
chore(travis): add code coverage report generation
This change adds a cmake configuration switch to enable code coverage instrumentation during the compilation of the project. When tests are executed, the instrumentation outputs coverage data to output files in the build directory. Programs such as lcov/gcovr can turn that data into reports. This change also adds steps to the travis CI configuration to build with this configuration switch and then use lcov to generate the consolidated report and publish to codecov.io
This commit is contained in:
parent
be167c9229
commit
f85f633346
11
.travis.yml
11
.travis.yml
|
@ -45,7 +45,18 @@ jobs:
|
||||||
- stage: Linux
|
- stage: Linux
|
||||||
os: linux
|
os: linux
|
||||||
env: JOB=build-ubuntu-16-04
|
env: JOB=build-ubuntu-16-04
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- lcov
|
||||||
script: "./.travis/$JOB.sh"
|
script: "./.travis/$JOB.sh"
|
||||||
|
after_success:
|
||||||
|
# Create lcov report
|
||||||
|
- lcov --directory _debug --capture --output-file coverage.info
|
||||||
|
# Filter out system headers and test sources
|
||||||
|
- lcov --remove coverage.info '/usr/*' '*/test/*' '*/*_autogen/*' --output-file coverage.info
|
||||||
|
# Upload report to codecov.io
|
||||||
|
- bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"
|
||||||
- stage: "Windows Stage 1: Dependencies (OpenSSL, Qt)"
|
- stage: "Windows Stage 1: Dependencies (OpenSSL, Qt)"
|
||||||
os: linux
|
os: linux
|
||||||
# Makes the cache this job creates avaiable only to jobs with WINDOWS_BUILD_ARCH_CACHE_TRICK_VARIABLE=i686,
|
# Makes the cache this job creates avaiable only to jobs with WINDOWS_BUILD_ARCH_CACHE_TRICK_VARIABLE=i686,
|
||||||
|
|
|
@ -203,9 +203,15 @@ build_qtox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_qtox() {
|
test_qtox() {
|
||||||
local BUILDDIR=_build
|
local BUILDDIR=_debug
|
||||||
|
|
||||||
|
cmake -H. -B"$BUILDDIR" \
|
||||||
|
-DUPDATE_CHECK=ON \
|
||||||
|
-DSTRICT_OPTIONS=ON \
|
||||||
|
-DCODE_COVERAGE=ON
|
||||||
|
|
||||||
cd $BUILDDIR
|
cd $BUILDDIR
|
||||||
|
make -j$(nproc)
|
||||||
make test
|
make test
|
||||||
cd -
|
cd -
|
||||||
}
|
}
|
||||||
|
|
|
@ -579,6 +579,20 @@ MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
|
||||||
# the compiler flags for compiling C++ sources
|
# the compiler flags for compiling C++ sources
|
||||||
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
|
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
|
||||||
|
|
||||||
|
# Interface library to propagate code coverage flags if enabled
|
||||||
|
add_library(coverage_config INTERFACE)
|
||||||
|
option(CODE_COVERAGE "Enable coverage reporting" OFF)
|
||||||
|
if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
target_compile_options(coverage_config INTERFACE -O0 -g --coverage)
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
|
||||||
|
target_link_options(coverage_config INTERFACE --coverage)
|
||||||
|
else()
|
||||||
|
target_link_libraries(coverage_config INTERFACE --coverage)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
link_libraries(coverage_config)
|
||||||
|
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
add_subdirectory(audio)
|
add_subdirectory(audio)
|
||||||
add_subdirectory(translations)
|
add_subdirectory(translations)
|
||||||
|
@ -589,7 +603,8 @@ add_library(${PROJECT_NAME}_static
|
||||||
${${PROJECT_NAME}_SOURCES})
|
${${PROJECT_NAME}_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}_static
|
target_link_libraries(${PROJECT_NAME}_static
|
||||||
${CMAKE_REQUIRED_LIBRARIES}
|
${CMAKE_REQUIRED_LIBRARIES}
|
||||||
${ALL_LIBRARIES})
|
${ALL_LIBRARIES}
|
||||||
|
coverage_config)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}_static util_library)
|
target_link_libraries(${PROJECT_NAME}_static util_library)
|
||||||
target_link_libraries(${PROJECT_NAME}_static audio_library)
|
target_link_libraries(${PROJECT_NAME}_static audio_library)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user