Merge lp:~pete-woods/unity-scopes-api/cmake-extras-for-coverage-report into lp:unity-scopes-api/devel

Proposed by Pete Woods
Status: Merged
Approved by: dobey
Approved revision: 697
Merged at revision: 697
Proposed branch: lp:~pete-woods/unity-scopes-api/cmake-extras-for-coverage-report
Merge into: lp:unity-scopes-api/devel
Diff against target: 333 lines (+2/-281)
6 files modified
CMakeLists.txt (+1/-2)
cmake/modules/EnableCoverageReport.cmake (+0/-166)
cmake/modules/FindLcov.cmake (+0/-29)
cmake/modules/Findgcovr.cmake (+0/-31)
cmake/modules/ParseArguments.cmake (+0/-52)
debian/control.in (+1/-1)
To merge this branch: bzr merge lp:~pete-woods/unity-scopes-api/cmake-extras-for-coverage-report
Reviewer Review Type Date Requested Status
dobey (community) Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+317981@code.launchpad.net

Commit message

Use cmake-extras for coverage reporting

Description of the change

Use cmake-extras for coverage reporting

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:697
https://jenkins.canonical.com/unity-api-1/job/lp-unity-scopes-api-ci/69/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1699
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1706
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1481
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1481/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-unity-scopes-api-ci/69/rebuild

review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-04-06 23:27:51 +0000
+++ CMakeLists.txt 2017-02-22 14:39:47 +0000
@@ -14,7 +14,6 @@
1414
15include(CheckCXXSourceCompiles)15include(CheckCXXSourceCompiles)
16CHECK_CXX_SOURCE_COMPILES("#ifdef __clang__\n#else\n#error \"Not clang.\"\n#endif\nint main(int argc, char **argv) { return 0; }" IS_CLANG)16CHECK_CXX_SOURCE_COMPILES("#ifdef __clang__\n#else\n#error \"Not clang.\"\n#endif\nint main(int argc, char **argv) { return 0; }" IS_CLANG)
17set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
1817
19if(IS_CLANG)18if(IS_CLANG)
20 message(STATUS "Compiling with Clang, disabling lttng.")19 message(STATUS "Compiling with Clang, disabling lttng.")
@@ -290,7 +289,7 @@
290 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage -g")289 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage -g")
291 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage -g")290 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage -g")
292endif()291endif()
293include(EnableCoverageReport)292find_package(CoverageReport)
294293
295# Tests294# Tests
296include(CTest)295include(CTest)
297296
=== removed directory 'cmake'
=== removed directory 'cmake/modules'
=== removed file 'cmake/modules/EnableCoverageReport.cmake'
--- cmake/modules/EnableCoverageReport.cmake 2013-05-29 04:57:50 +0000
+++ cmake/modules/EnableCoverageReport.cmake 1970-01-01 00:00:00 +0000
@@ -1,166 +0,0 @@
1# - Creates a special coverage build type and target on GCC.
2#
3# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
4# for selected targets. Optional arguments to this function are used to filter
5# unwanted results using globbing expressions. Moreover targets with tests for
6# the source code can be specified to trigger regenerating the report if the
7# test has changed
8#
9# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
10#
11# To generate a coverage report first build the project with
12# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
13#
14# The coverage report is based on gcov. Depending on the availability of lcov
15# a HTML report will be generated and/or an XML report of gcovr is found.
16# The generated coverage target executes all found solutions. Special targets
17# exist to create e.g. only the xml report: coverage-xml.
18#
19# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
20#
21# This program is free software; you can redistribute it
22# and/or modify it under the terms of the GNU General
23# Public License as published by the Free Software Foundation;
24# either version 2, or (at your option)
25# any later version.
26#
27# This program is distributed in the hope that it will be useful,
28# but WITHOUT ANY WARRANTY; without even the implied warranty of
29# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30# GNU General Public License for more details.
31#
32
33INCLUDE(ParseArguments)
34
35FIND_PACKAGE(Lcov)
36FIND_PACKAGE(gcovr)
37
38FUNCTION(ENABLE_COVERAGE_REPORT)
39
40 # argument parsing
41 PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
42
43 SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
44 SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
45 SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
46 SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
47 SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
48
49 # decide if there is any tool to create coverage data
50 SET(TOOL_FOUND FALSE)
51 IF(LCOV_FOUND OR GCOVR_FOUND)
52 SET(TOOL_FOUND TRUE)
53 ENDIF()
54 IF(NOT TOOL_FOUND)
55 MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
56 ENDIF()
57
58 STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
59 IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
60
61 MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
62
63 # create coverage build type
64 SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
65 SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
66 SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
67
68 # instrument targets
69 SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
70 LINK_FLAGS --coverage)
71
72 # html report
73 IF (LCOV_FOUND)
74
75 MESSAGE(STATUS "Enabling HTML coverage report")
76
77 # set up coverage target
78
79 ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
80 COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
81 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
82 COMMENT "Collecting coverage data"
83 DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
84 VERBATIM)
85
86 # filter unwanted stuff
87 LIST(LENGTH ARG_FILTER FILTER_LENGTH)
88 IF(${FILTER_LENGTH} GREATER 0)
89 SET(FILTER COMMAND ${LCOV_EXECUTABLE})
90 FOREACH(F ${ARG_FILTER})
91 SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
92 ENDFOREACH()
93 SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
94 ELSE()
95 SET(FILTER "")
96 ENDIF()
97
98 ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
99 COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
100 ${FILTER}
101 DEPENDS ${COVERAGE_RAW_FILE}
102 COMMENT "Filtering recorded coverage data for project-relevant entries"
103 VERBATIM)
104 ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
105 COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
106 COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
107 DEPENDS ${COVERAGE_FILTERED_FILE}
108 COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
109 VERBATIM)
110
111 ADD_CUSTOM_TARGET(coverage-html
112 DEPENDS ${COVERAGE_REPORT_DIR})
113
114 ENDIF()
115
116 # xml coverage report
117 IF(GCOVR_FOUND)
118
119 MESSAGE(STATUS "Enabling XML coverage report")
120
121 # filter unwanted stuff
122 SET(GCOV_FILTER "")
123 LIST(LENGTH ARG_FILTER FILTER_LENGTH)
124 IF(${FILTER_LENGTH} GREATER 0)
125 FOREACH(F ${ARG_FILTER})
126 SET(GCOV_FILTER "${GCOV_FILTER} -e \"${F}\"")
127 ENDFOREACH()
128 ENDIF()
129
130 # gcovr cannot write directly to a file so the execution needs to
131 # be wrapped in a cmake file that generates the file output
132 FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
133 "SET(ENV{LANG} en)\n")
134 FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
135 "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" ${GCOV_FILTER} OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
136
137 ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
138 COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
139 COMMENT "Generating coverage XML report"
140 VERBATIM)
141
142 ADD_CUSTOM_TARGET(coverage-xml
143 DEPENDS ${COVERAGE_XML_FILE})
144
145 ENDIF()
146
147 # provide a global coverage target executing both steps if available
148 SET(GLOBAL_DEPENDS "")
149 IF(LCOV_FOUND)
150 LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
151 ENDIF()
152 IF(GCOVR_FOUND)
153 LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
154 ENDIF()
155 IF(LCOV_FOUND OR GCOVR_FOUND)
156 ADD_CUSTOM_TARGET(coverage
157 DEPENDS ${GLOBAL_DEPENDS})
158 ENDIF()
159
160 ENDIF()
161
162 # This gets rid of any stale .gcda files. Run this if a running a binary causes lots of messages about
163 # about a "merge mismatch for summaries".
164 ADD_CUSTOM_TARGET(clean-coverage COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
165
166ENDFUNCTION()
1670
=== removed file 'cmake/modules/FindLcov.cmake'
--- cmake/modules/FindLcov.cmake 2013-05-29 04:57:50 +0000
+++ cmake/modules/FindLcov.cmake 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1# - Find lcov
2# Will define:
3#
4# LCOV_EXECUTABLE - the lcov binary
5# GENHTML_EXECUTABLE - the genhtml executable
6#
7# Copyright (C) 2010 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
8#
9# This program is free software; you can redistribute it
10# and/or modify it under the terms of the GNU General
11# Public License as published by the Free Software Foundation;
12# either version 2, or (at your option)
13# any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20
21INCLUDE(FindPackageHandleStandardArgs)
22
23FIND_PROGRAM(LCOV_EXECUTABLE lcov)
24FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
25
26FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
27
28# only visible in advanced view
29MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
300
=== removed file 'cmake/modules/Findgcovr.cmake'
--- cmake/modules/Findgcovr.cmake 2013-05-29 04:57:50 +0000
+++ cmake/modules/Findgcovr.cmake 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
1# - Find gcovr scrip
2# Will define:
3#
4# GCOVR_EXECUTABLE - the gcovr script
5#
6# Uses:
7#
8# GCOVR_ROOT - root to search for the script
9#
10# Copyright (C) 2011 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
11#
12# This program is free software; you can redistribute it
13# and/or modify it under the terms of the GNU General
14# Public License as published by the Free Software Foundation;
15# either version 2, or (at your option)
16# any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23
24INCLUDE(FindPackageHandleStandardArgs)
25
26FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
27
28FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
29
30# only visible in advanced view
31MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
320
=== removed file 'cmake/modules/ParseArguments.cmake'
--- cmake/modules/ParseArguments.cmake 2013-05-29 04:57:50 +0000
+++ cmake/modules/ParseArguments.cmake 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1# Parse arguments passed to a function into several lists separated by
2# upper-case identifiers and options that do not have an associated list e.g.:
3#
4# SET(arguments
5# hello OPTION3 world
6# LIST3 foo bar
7# OPTION2
8# LIST1 fuz baz
9# )
10# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
11#
12# results in 7 distinct variables:
13# * ARG_DEFAULT_ARGS: hello;world
14# * ARG_LIST1: fuz;baz
15# * ARG_LIST2:
16# * ARG_LIST3: foo;bar
17# * ARG_OPTION1: FALSE
18# * ARG_OPTION2: TRUE
19# * ARG_OPTION3: TRUE
20#
21# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
22
23MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
24 SET(DEFAULT_ARGS)
25 FOREACH(arg_name ${arg_names})
26 SET(${prefix}_${arg_name})
27 ENDFOREACH(arg_name)
28 FOREACH(option ${option_names})
29 SET(${prefix}_${option} FALSE)
30 ENDFOREACH(option)
31
32 SET(current_arg_name DEFAULT_ARGS)
33 SET(current_arg_list)
34 FOREACH(arg ${ARGN})
35 SET(larg_names ${arg_names})
36 LIST(FIND larg_names "${arg}" is_arg_name)
37 IF (is_arg_name GREATER -1)
38 SET(${prefix}_${current_arg_name} ${current_arg_list})
39 SET(current_arg_name ${arg})
40 SET(current_arg_list)
41 ELSE (is_arg_name GREATER -1)
42 SET(loption_names ${option_names})
43 LIST(FIND loption_names "${arg}" is_option)
44 IF (is_option GREATER -1)
45 SET(${prefix}_${arg} TRUE)
46 ELSE (is_option GREATER -1)
47 SET(current_arg_list ${current_arg_list} ${arg})
48 ENDIF (is_option GREATER -1)
49 ENDIF (is_arg_name GREATER -1)
50 ENDFOREACH(arg)
51 SET(${prefix}_${current_arg_name} ${current_arg_list})
52ENDMACRO(PARSE_ARGUMENTS)
530
=== modified file 'debian/control.in'
--- debian/control.in 2016-11-28 05:06:26 +0000
+++ debian/control.in 2017-02-22 14:39:47 +0000
@@ -6,7 +6,7 @@
6 capnproto,6 capnproto,
7 click-dev (>= 0.2.2),7 click-dev (>= 0.2.2),
8 cmake,8 cmake,
9 cmake-extras (>= 0.4),9 cmake-extras (>= 0.10),
10 dbus-test-runner,10 dbus-test-runner,
11 debhelper (>= 9),11 debhelper (>= 9),
12 devscripts,12 devscripts,

Subscribers

People subscribed via source and target branches

to all changes: