From f79286bd35a20d593f2b3db82dd6a642c47910a9 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Wed, 3 Jul 2019 19:18:02 +0200
Subject: [PATCH] Force removing of .gcda files to avoid merging of obsolete
 files

These merge could generate coverage failures
One should use cmake commands instead of unix find+rm for portability
---
 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c9ebb66d..5ee1a5562 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -250,9 +250,16 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage")
 
   set(GCOVR_OPTIONS --object-directory="${PUGS_BINARY_DIR}" -r "${PUGS_SOURCE_DIR}/src" ${GCOVR_EXCLUDE} ${GCOVR_EXTRA})
 
+  add_custom_target(coverage-clean-up
+    ALL
+    COMMAND find "${PUGS_BINARY_DIR}" -name \*.gcda -exec rm -f {} +;
+    COMMENT "Removing obsolete gcda to perform a net coverage."
+    )
+
   add_custom_target(coverage
     ALL
     COMMAND ${GCOVR} ${GCOVR_OPTIONS} --exclude-unreachable-branches --sort-percentage
+    DEPENDS coverage-clean-up
     DEPENDS run_unit_tests pugs
     COMMENT "Running gcovr to build coverage report."
     )
-- 
GitLab