Skip to content

Commit 300745f

Browse files
committed
feat: script & custom target for cleaning old coverage output
1 parent 93dc7e5 commit 300745f

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
env:
114114
BUILD_NAME: ${{ github.head_ref || github.ref_name }}.${{ matrix.os }}.${{ matrix.preset }}.${{ matrix.config }}
115115
CMAKE_OSX_ARCHITECTURES: arm64;x86_64
116-
run: cmake --preset ${{ matrix.preset }} -D BENBOT_DOCS=OFF -D BUILDNAME=${{ env.BUILD_NAME }}
116+
run: cmake --preset ${{ matrix.preset }} -D BENBOT_DOCS=OFF -D BUILDNAME=${{ env.BUILD_NAME }} --log-level=VERBOSE
117117

118118
- name: Build and test
119119
run: |

config/cmake/Coverage.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414

1515
include_guard (GLOBAL)
1616

17+
include (FeatureSummary)
18+
19+
add_feature_info (
20+
coverage [[CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT WIN32]]
21+
"Enabled coverage reporting flags for debug configurations"
22+
)
23+
1724
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT WIN32)
1825
get_cmake_property (debug_configs DEBUG_CONFIGURATIONS)
1926

@@ -38,5 +45,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT WIN32)
3845
link_libraries ("$<${config_debug}:gcov>")
3946
endif ()
4047

41-
message (STATUS "Coverage enabled")
48+
set (clean_script "${CMAKE_SOURCE_DIR}/scripts/CleanOldCoverageOutput.cmake")
49+
50+
add_custom_target (
51+
coverage-clean
52+
COMMAND "${CMAKE_COMMAND}" -D "BUILD_DIR=${CMAKE_BINARY_DIR}" -P "${clean_script}"
53+
COMMENT "Cleaning old coverage output files..."
54+
VERBATIM USES_TERMINAL
55+
SOURCES "${clean_script}"
56+
)
4257
endif ()

config/cmake/Sanitizers.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ function (__add_build_config name flags linkerFlags)
6262
CMAKE_CXX_FLAGS_${name} CMAKE_C_FLAGS_${name} CMAKE_EXE_LINKER_FLAGS_${name}
6363
CMAKE_SHARED_LINKER_FLAGS_${name} CMAKE_MODULE_LINKER_FLAGS_${name}
6464
)
65+
66+
message (VERBOSE "Added build configuration ${name}")
6567
endfunction ()
6668

6769
# ASAN
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ======================================================================================
2+
#
3+
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
4+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
5+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6+
# ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9+
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
10+
#
11+
# ======================================================================================
12+
13+
#[[
14+
This script can be run to remove all old coverage files in a build directory.
15+
16+
Example usage (from repo root):
17+
cmake -D BUILD_DIR=$(pwd)/Builds/clang -P scripts/CleanOldCoverageOutput.cmake
18+
]]
19+
20+
cmake_minimum_required (VERSION 4.0.0 FATAL_ERROR)
21+
22+
if (NOT DEFINED BUILD_DIR)
23+
message (FATAL_ERROR "BUILD_DIR not defined!")
24+
endif ()
25+
26+
file (GLOB_RECURSE coverage_files LIST_DIRECTORIES false
27+
"${BUILD_DIR}/*.gcda" "${BUILD_DIR}/*.gcov" "${BUILD_DIR}/*.profraw"
28+
)
29+
30+
if (coverage_files)
31+
file (REMOVE ${coverage_files})
32+
list (LENGTH coverage_files num_files)
33+
message (STATUS "Removed ${num_files} files.")
34+
else ()
35+
message (STATUS "No coverage files found.")
36+
endif ()

0 commit comments

Comments
 (0)