Skip to content

Commit

Permalink
added code coverage test into linux gcc workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
moaazassali committed Jul 6, 2024
1 parent 0a4b2ad commit 30f0886
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
build_type: Coverage
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
Expand Down Expand Up @@ -65,3 +66,11 @@ jobs:
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

- name: Code Coverage
if: matrix.c_compiler == 'gcc'
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
sudo apt-get update
sudo apt-get install -y gcovr
gcovr -r .. -f ../src
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ target_include_directories(${PROJECT_NAME}-tests
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/dependencies/doctest/scripts/cmake")
include(doctest)

doctest_discover_tests(${PROJECT_NAME}-tests)
doctest_discover_tests(${PROJECT_NAME}-tests)


# ========================================
# Code Coverage
# ========================================
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
SET(CMAKE_CXX_FLAGS "-g -O0 --coverage")
SET(CMAKE_C_FLAGS "-g -O0 --coverage")
endif ()

0 comments on commit 30f0886

Please sign in to comment.