Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage #16

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@ jobs:
# working-directory: ${{github.workspace}}/build
# run: ctest -C ${{env.BUILD_TYPE}}

coverage:
runs-on: ubuntu-latest
env:
BUILD_TYPE: Debug
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
run: ./vtkdiff --help
- name: Coverage
working-directory: ${{github.workspace}}/build
run: pipx run gcovr -r ${{github.workspace}} --exclude ${{github.workspace}}/build/_deps

22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ if(NOT VTK_FOUND)
endif()
# --- CPM end ---

# Coverage (enabled by Debug-config)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND ${PROJECT_SOURCE_DIR} STREQUAL
${CMAKE_SOURCE_DIR}
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-g -Og --coverage")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fprofile-abs-path")
endif()
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "--coverage")
message(STATUS "Setting coverage flags!")
message(
STATUS
"Run executables and the run:\n gcovr -r ${PROJECT_SOURCE_DIR}"
)
else()
message(FATAL_ERROR "OGS_COVERAGE requires clang or gcc compiler!")
endif()
endif()

add_executable(vtkdiff vtkdiff.cpp)
target_link_libraries(vtkdiff tclap VTK::IOXML)

Expand Down