[CI] Measure code coverage after unit test
This commit is contained in:
parent
8c2c7b6cb5
commit
7497cb26a5
3 changed files with 18 additions and 2 deletions
1
extras/test/unit/.gitignore
vendored
1
extras/test/unit/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
build/
|
||||
lcov*
|
||||
|
|
|
@ -18,11 +18,13 @@ add_executable(${PROJECT_NAME} ${TEST_SOURCES})
|
|||
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
||||
|
||||
# link RadioLib
|
||||
target_link_libraries(${PROJECT_NAME} RadioLib fmt)
|
||||
target_link_libraries(${PROJECT_NAME} RadioLib fmt gcov)
|
||||
|
||||
# set target properties and options
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
|
||||
set(BUILD_FLAGS -Wall -Wextra -fprofile-arcs -ftest-coverage -O0)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${BUILD_FLAGS})
|
||||
target_compile_options(RadioLib PRIVATE ${BUILD_FLAGS})
|
||||
|
||||
# set RadioLib debug
|
||||
#target_compile_definitions(RadioLib PUBLIC RADIOLIB_DEBUG_BASIC RADIOLIB_DEBUG_SPI RADIOLIB_DEBUG_PROTOCOL)
|
||||
|
|
13
extras/test/unit/coverage.sh
Executable file
13
extras/test/unit/coverage.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
filename="lcov"
|
||||
rm -rf $filename.*
|
||||
lcov --capture --directory build --output-file "${filename}.info"
|
||||
|
||||
# filter out boost and C++ standard library
|
||||
lcov --remove "${filename}.info" "/usr/*/boost/*" "/usr/include/c++/*" --output-file "${filename}.info"
|
||||
|
||||
# generate HTML
|
||||
genhtml "${filename}.info" --output-directory "${filename}.report"
|
||||
zip -r "${filename}.report.zip" "${filename}.report"
|
Loading…
Add table
Reference in a new issue