diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2b4d188..104c75df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,14 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Configure code + if: matrix.os == 'ubuntu-latest' + run: cmake -Bbuild -DENABLE_COVERAGE=1 + - name: Configure code + if: matrix.os == 'macos-latest' run: cmake -Bbuild - name: Build code run: cmake --build build --parallel - name: Test code run: ctest --test-dir build -V + - name: collect code coverage + run: bash <(curl -s https://codecov.io/bash) || echo "codecov failure" diff --git a/cmake/options.cmake b/cmake/options.cmake index ebbf749b..005f51e1 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,5 +1,6 @@ option(BUILD_SHARED_LIBS "Build the shared library" ON) option(BUILD_EXAMPLES "Build the examples" ON) option(ENABLE_UNIT_TESTS "Enable unit testing" ON) +option(ENABLE_COVERAGE "Enable unit test coverage" OFF) set(TEST_COMM_SIZE "2" CACHE STRING "MPI Communicator Size for tests") option(ENABLE_JENKINS_OUTPUT "Enable xml output for unit tests" OFF) diff --git a/cmake/testing.cmake b/cmake/testing.cmake index a1d4e61e..932648a0 100644 --- a/cmake/testing.cmake +++ b/cmake/testing.cmake @@ -10,8 +10,15 @@ if (ENABLE_UNIT_TESTS) FetchContent_MakeAvailable(googletest) add_library(googletest INTERFACE IMPORTED) target_link_libraries(googletest INTERFACE gtest_main) + + if(ENABLE_COVERAGE) + target_compile_options(googletest INTERFACE -O0 -g -fprofile-arcs -ftest-coverage) + target_link_options(googletest INTERFACE -fprofile-arcs -ftest-coverage) + endif() endif() + + #function(add_unit target sources) # set(mpimain_SRC ${CMAKE_SOURCE_DIR}/raptor/tests/mpi_main.cpp) # add_executable(${target} ${sources} ${mpimain_SRC})