Skip to content

Commit 94f5395

Browse files
committed
Add code coverage generation.
1 parent 930190e commit 94f5395

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.github/workflows/cmake-multi-platform.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
6363
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6464
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
65+
-DCODE_COVERAGE=ON
6566
-S ${{ github.workspace }}
6667
6768
- name: Build

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0)
33
project(buffer_set)
44

55
option(BUILD_TESTS "Build tests" ON)
6+
option(CODE_COVERAGE "Enable code coverage reporting" OFF)
67

78
include_directories(include)
89

@@ -14,6 +15,11 @@ set(LIB_SRCS
1415
add_library(buffer_set STATIC ${LIB_SRCS})
1516

1617
if(BUILD_TESTS)
18+
if(CODE_COVERAGE AND CMAKE_C_COMPILER_ID MATCHES "GNU")
19+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
20+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
21+
endif()
22+
1723
set(TEST_SRCS
1824
tests/clear.c
1925
tests/insert.c

0 commit comments

Comments
 (0)