aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodney Dawes <rodney.dawes@canonical.com>2017-02-02 15:52:03 -0500
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:38:27 +0200
commite4fe97eba0160a4d9b1282732cbaea7f8dfb4c7d (patch)
tree7b9b0784b5a388d2be48920f712c15a0f32dfa00
parent5b555e5b0d23aa429d26795183a63653ef440c77 (diff)
downloadayatana-indicator-datetime-e4fe97eba0160a4d9b1282732cbaea7f8dfb4c7d.tar.gz
ayatana-indicator-datetime-e4fe97eba0160a4d9b1282732cbaea7f8dfb4c7d.tar.bz2
ayatana-indicator-datetime-e4fe97eba0160a4d9b1282732cbaea7f8dfb4c7d.zip
Use cmake-extras for coverage support and always enable testing.
-rw-r--r--CMakeLists.txt10
-rw-r--r--cmake/GCov.cmake51
-rw-r--r--m4/gcov.m486
-rw-r--r--src/CMakeLists.txt6
-rwxr-xr-xtrim-lcov.py57
5 files changed, 9 insertions, 201 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1aebdf3..1378fe4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,9 +94,6 @@ add_custom_target (dist
COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-add_custom_target (clean-coverage
- COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
-
add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/tests)
@@ -126,7 +123,12 @@ if (${ENABLE_TESTS})
pkg_check_modules (DBUSTEST REQUIRED dbustest-1>=14.04.0)
enable_testing ()
if (${ENABLE_COVERAGE})
- include(GCov)
+ find_package(CoverageReport)
+ ENABLE_COVERAGE_REPORT(
+ TARGETS indicatordatetimeservice indicator-datetime-service
+ TESTS test-actions test-alarm-queue test-clock test-datetime test-exporter test-formatter test-live-actions test-locations test-menu-appointments test-menus test-notification test-notification-response test-planner test-settings test-sound test-timezone-timedated test-utils test-eds-ics-all-day-events test-eds-ics-repeating-events test-eds-ics-nonrepeating-events test-eds-ics-repeating-valarms test-eds-ics-missing-trigger test-eds-ics-tzids test-eds-ics-tzids-2 test-eds-ics-tzids-utc test-eds-ics-non-attending-alarms test-eds-ics-repeating-events-with-individual-change manual-test-snap
+ FILTER /usr/include ${CMAKE_BINARY_DIR}/*
+ )
endif ()
endif ()
diff --git a/cmake/GCov.cmake b/cmake/GCov.cmake
deleted file mode 100644
index 9a5086e..0000000
--- a/cmake/GCov.cmake
+++ /dev/null
@@ -1,51 +0,0 @@
-if (CMAKE_BUILD_TYPE MATCHES coverage)
- set(GCOV_FLAGS "${GCOV_FLAGS} --coverage")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}")
- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}")
- set(GCOV_LIBS ${GCOV_LIBS} gcov)
-
- find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
- if (NOT GCOVR_EXECUTABLE)
- message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
- else ()
- message(STATUS "Gcovr found, can generate XML coverage info.")
- add_custom_target (coverage-xml
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
- --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
- endif()
-
- find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
- find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
- if (NOT LCOV_EXECUTABLE)
- message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
- else ()
- if(NOT GENHTML_EXECUTABLE)
- message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
- else()
- message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
- add_custom_target (coverage-html
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose
- COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info
- COMMAND "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info
- COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-lcov.info
- COMMAND ${CMAKE_COMMAND} -E echo ""
- COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html"
- COMMAND ${CMAKE_COMMAND} -E echo "")
- #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
- #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
- #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
- #)
- endif()
- endif()
-endif()
-
-
- #$(MAKE) $(AM_MAKEFLAGS) check
- #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info
- #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
- #@echo
- #@echo " file://$(abs_top_builddir)/lcov-html/index.html"
- #@echo
diff --git a/m4/gcov.m4 b/m4/gcov.m4
deleted file mode 100644
index d243eeb..0000000
--- a/m4/gcov.m4
+++ /dev/null
@@ -1,86 +0,0 @@
-# Checks for existence of coverage tools:
-# * gcov
-# * lcov
-# * genhtml
-# * gcovr
-#
-# Sets ac_cv_check_gcov to yes if tooling is present
-# and reports the executables to the variables LCOV, GCOVR and GENHTML.
-AC_DEFUN([AC_TDD_GCOV],
-[
- AC_ARG_ENABLE(gcov,
- AS_HELP_STRING([--enable-gcov],
- [enable coverage testing with gcov]),
- [use_gcov=$enableval], [use_gcov=no])
-
- if test "x$use_gcov" = "xyes"; then
- # we need gcc:
- if test "$GCC" != "yes"; then
- AC_MSG_ERROR([GCC is required for --enable-gcov])
- fi
-
- # Check if ccache is being used
- AC_CHECK_PROG(SHTOOL, shtool, shtool)
- case `$SHTOOL path $CC` in
- *ccache*[)] gcc_ccache=yes;;
- *[)] gcc_ccache=no;;
- esac
-
- if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
- AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
- fi
-
- lcov_version_list="1.6 1.7 1.8 1.9"
- AC_CHECK_PROG(LCOV, lcov, lcov)
- AC_CHECK_PROG(GENHTML, genhtml, genhtml)
-
- if test "$LCOV"; then
- AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
- glib_cv_lcov_version=invalid
- lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
- for lcov_check_version in $lcov_version_list; do
- if test "$lcov_version" = "$lcov_check_version"; then
- glib_cv_lcov_version="$lcov_check_version (ok)"
- fi
- done
- ])
- else
- lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
- AC_MSG_ERROR([$lcov_msg])
- fi
-
- case $glib_cv_lcov_version in
- ""|invalid[)]
- lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
- AC_MSG_ERROR([$lcov_msg])
- LCOV="exit 0;"
- ;;
- esac
-
- if test -z "$GENHTML"; then
- AC_MSG_ERROR([Could not find genhtml from the lcov package])
- fi
-
- ac_cv_check_gcov=yes
- ac_cv_check_lcov=yes
-
- # Remove all optimization flags from CFLAGS
- changequote({,})
- CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
- changequote([,])
-
- # Add the special gcc flags
- COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
- COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
- COVERAGE_LDFLAGS="-lgcov"
-
- # Check availability of gcovr
- AC_CHECK_PROG(GCOVR, gcovr, gcovr)
- if test -z "$GCOVR"; then
- ac_cv_check_gcovr=no
- else
- ac_cv_check_gcovr=yes
- fi
-
-fi
-]) # AC_TDD_GCOV
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 823a9b8..37baf86 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -57,9 +57,9 @@ endif()
# add warnings/coverage info on handwritten files
# but not the autogenerated ones...
set_source_files_properties(${SERVICE_CXX_SOURCES}
- PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${GCOV_FLAGS} -g -std=c++11")
+ PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -g -std=c++11")
set_source_files_properties(${SERVICE_C_SOURCES}
- PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${GCOV_FLAGS} -g -std=c99")
+ PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -g -std=c99")
# add the bin dir to our include path so our code can find the generated header files
include_directories (${CMAKE_CURRENT_BINARY_DIR})
@@ -70,5 +70,5 @@ link_directories (${SERVICE_DEPS_LIBRARY_DIRS})
add_executable (${SERVICE_EXEC} main.cpp)
set_source_files_properties(${SERVICE_SOURCES} main.cpp PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -g -std=c++11")
-target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${GCOV_LIBS})
+target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES})
install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})
diff --git a/trim-lcov.py b/trim-lcov.py
deleted file mode 100755
index 2cd8dee..0000000
--- a/trim-lcov.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-# This script removes branch and/or line coverage data for lines that
-# contain a particular substring.
-#
-# In the interest of "fairness" it removes all branch or coverage data
-# when a match is found -- not just negative data. It is therefore
-# likely that running this script will actually reduce the total number
-# of lines and branches that are marked as covered (in absolute terms).
-#
-# This script intentionally avoids checking for errors. Any exceptions
-# will trigger make to fail.
-#
-# Author: Ryan Lortie <desrt@desrt.ca>
-
-import sys
-
-line_suppress = ['g_assert_not_reached']
-branch_suppress = ['g_assert', 'g_return_if_fail', 'g_clear_object', 'g_clear_pointer', 'g_return_val_if_fail', 'G_DEFINE_TYPE']
-
-def check_suppress(suppressions, source, data):
- line, _, rest = data.partition(',')
- line = int(line) - 1
-
- assert line < len(source)
-
- for suppression in suppressions:
- if suppression in source[line]:
- return True
-
- return False
-
-source = []
-for line in sys.stdin:
- line = line[:-1]
-
- keyword, _, rest = line.partition(':')
-
- # Source file
- if keyword == 'SF':
-
- with open(rest, 'r') as pFile:
-
- source = pFile.readlines()
-
- # Branch coverage data
- elif keyword == 'BRDA':
- if check_suppress(branch_suppress, source, rest):
- continue
-
- # Line coverage data
- elif keyword == 'DA':
- if check_suppress(line_suppress, source, rest):
- continue
-
- print(line)