@@ -20,12 +20,19 @@ jobs:
|
||||
git fetch --depth 1 origin ${{ github.sha }}
|
||||
git checkout FETCH_HEAD
|
||||
- name: Configure
|
||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build --config Release -j "$(nproc)"
|
||||
run: cmake --build build --config Debug -j "$(nproc)"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build
|
||||
ctest --output-on-failure
|
||||
|
||||
- name: Coverage
|
||||
run: |
|
||||
lcov --capture --directory build --output-file build/coverage.info
|
||||
lcov --remove build/coverage.info "/usr/*" "*/build/*" "*/_deps/*" --output-file build/coverage.info
|
||||
lcov --summary build/coverage.info
|
||||
genhtml build/coverage.info --output-directory build/coverage-html
|
||||
|
||||
@@ -4,6 +4,8 @@ project(bar)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
option(ENABLE_COVERAGE "Enable coverage flags" OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
@@ -73,6 +75,11 @@ target_include_directories(bar_tests PRIVATE
|
||||
)
|
||||
target_link_libraries(bar_tests PRIVATE Catch2::Catch2WithMain)
|
||||
|
||||
if(ENABLE_COVERAGE)
|
||||
target_compile_options(bar_tests PRIVATE -O0 -g --coverage)
|
||||
target_link_options(bar_tests PRIVATE --coverage)
|
||||
endif()
|
||||
|
||||
include(Catch)
|
||||
catch_discover_tests(bar_tests)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user