aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt24
-rw-r--r--cmake/lcov.cmake66
-rw-r--r--debian/control1
-rw-r--r--tests/client/CMakeLists.txt12
4 files changed, 23 insertions, 80 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0aef573..43d4098 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,20 +18,6 @@ add_definitions(-DQT_NO_KEYWORDS)
find_program(DBUS_RUNNER dbus-test-runner)
-# Cooverage tools
-OPTION(ENABLE_COVERAGE "Build with coverage analysis support" OFF)
-if(ENABLE_COVERAGE)
- message(STATUS "Using coverage flags")
- find_program(COVERAGE_COMMAND gcov)
- if(NOT COVERAGE_COMMAND)
- message(FATAL_ERROR "gcov command not found")
- endif()
- SET(CMAKE_C_FLAGS "-g -O0 -Wall --coverage")
- SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -std=c++11 --coverage")
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
- include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake)
-endif()
-
add_subdirectory(libqmenumodel)
# Tests Tools
@@ -61,3 +47,13 @@ if(GENERATE_DOC)
endif()
endif()
+# Coverage
+#####################################################################
+# Enable code coverage calculation with gcov/gcovr/lcov
+# Usage:
+# * Switch build type to coverage (use ccmake or cmake-gui)
+# * Invoke make, make test, make coverage (or ninja if you use that backend)
+# * Find html report in subdir coveragereport
+# * Find xml report feasible for jenkins in coverage.xml
+#####################################################################
+find_package(CoverageReport)
diff --git a/cmake/lcov.cmake b/cmake/lcov.cmake
deleted file mode 100644
index 152bbea..0000000
--- a/cmake/lcov.cmake
+++ /dev/null
@@ -1,66 +0,0 @@
-# - This module creates a new 'lcov' target which generates
-# a coverage analysis html output.
-# LCOV is a graphical front-end for GCC's coverage testing tool gcov. Please see
-# http://ltp.sourceforge.net/coverage/lcov.php
-#
-# Usage: you must add an option to your CMakeLists.txt to build your application
-# with coverage support. Then you need to include this file to the lcov target.
-#
-# Example:
-# IF(BUILD_WITH_COVERAGE)
-# SET(CMAKE_C_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
-# SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
-# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
-# include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake)
-# ENDIF(BUILD_WITH_COVERAGE)
-#=============================================================================
-# Copyright 2010 ascolab GmbH
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distributed this file outside of CMake, substitute the full
-# License text for the above reference.)
-
-set(REMOVE_PATTERN
- q*.h
- *.moc
- moc_*.cpp
- locale_facets.h
- new)
-
-## lcov target
-ADD_CUSTOM_TARGET(lcov)
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND mkdir -p coverage
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND lcov --directory . --zerocounters
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND make test
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND lcov --directory . --capture --output-file ./coverage/stap_all.info --no-checksum --compat-libtool
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND lcov --directory . -r ./coverage/stap_all.info ${REMOVE_PATTERN} --output-file ./coverage/stap.info
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND genhtml -o ./coverage --title "Code Coverage" --legend --show-details --demangle-cpp ./coverage/stap.info
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-ADD_CUSTOM_COMMAND(TARGET lcov
- COMMAND echo "Open ${CMAKE_BINARY_DIR}/coverage/index.html to view the coverage analysis results."
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- )
-
diff --git a/debian/control b/debian/control
index c1e7c70..119ea08 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,7 @@ Priority: optional
Maintainer: Marius Gripsgard <marius@ubports.com>
Build-Depends: debhelper (>= 9.0.0),
cmake (>= 2.8.9),
+ cmake-extras,
libglib2.0-dev,
qt5-default,
qt5-qmake,
diff --git a/tests/client/CMakeLists.txt b/tests/client/CMakeLists.txt
index ed2f1aa..ce8192d 100644
--- a/tests/client/CMakeLists.txt
+++ b/tests/client/CMakeLists.txt
@@ -23,6 +23,7 @@ macro(declare_test testname)
TIMEOUT ${CTEST_TESTING_TIMEOUT}
ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};QT_QPA_PLATFORM=minimal")
+ set(TESTS ${TESTS} ${testname})
endmacro(declare_test testname)
macro(declare_simple_test testname)
@@ -64,3 +65,14 @@ declare_test(unitymenuactiontest)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/qmlfiles.h.in
${CMAKE_CURRENT_BINARY_DIR}/qmlfiles.h)
+
+find_package(CoverageReport)
+enable_coverage_report(
+ TARGETS
+ qmenumodel
+ FILTER
+ ${CMAKE_SOURCE_DIR}/tests/*
+ ${CMAKE_BINARY_DIR}/*
+ TESTS
+ ${TESTS}
+)