Merge lp:~dobey/indicator-power/fix-coverage into lp:indicator-power

Proposed by dobey on 2017-02-07
Status: Superseded
Proposed branch: lp:~dobey/indicator-power/fix-coverage
Merge into: lp:indicator-power
Diff against target: 212 lines (+22/-117)
5 files modified
CMakeLists.txt (+9/-20)
cmake/GCov.cmake (+0/-51)
debian/control (+4/-1)
tests/CMakeLists.txt (+9/-7)
tests/Makefile.am.strings (+0/-38)
To merge this branch: bzr merge lp:~dobey/indicator-power/fix-coverage
Reviewer Review Type Date Requested Status
Indicator Applet Developers 2017-02-07 Pending
Review via email: mp+316620@code.launchpad.net

Commit message

Use coverage support from cmake-extras.

To post a comment you must log in.
307. By dobey on 2017-02-07

Remove usage of extra GCOV variables.

308. By dobey on 2017-02-10

Remove hard-coded -g compiler flag.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-05-16 18:09:57 +0000
3+++ CMakeLists.txt 2017-02-07 20:08:15 +0000
4@@ -13,9 +13,6 @@
5 -DLOW_BATTERY_SOUND="Low battery.ogg"
6 )
7
8-option (enable_tests "Build the package's automatic tests." ON)
9-option (enable_lcov "Generate lcov code coverage reports." ON)
10-
11 set(SERVICE_LIB "indicatorpowerservice")
12 set(SERVICE_EXEC "indicator-power-service")
13 add_definitions(-DSERVICE_EXEC="${SERVICE_EXEC}")
14@@ -59,9 +56,6 @@
15 COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
16 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
17
18-add_custom_target (clean-coverage
19- COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
20-
21 add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
22 ${CMAKE_SOURCE_DIR}/src
23 ${CMAKE_SOURCE_DIR}/tests)
24@@ -83,22 +77,17 @@
25 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
26 include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
27
28-# testing & coverage
29-if (${enable_tests})
30- set (GTEST_SOURCE_DIR /usr/src/gtest/src)
31- set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..)
32- set (GTEST_LIBS -lpthread)
33- enable_testing ()
34- if (${enable_lcov})
35- include(GCov)
36- endif ()
37-endif ()
38-
39 # actually build things
40 add_subdirectory(src)
41 add_subdirectory(data)
42 add_subdirectory(po)
43-if (${enable_tests})
44- add_subdirectory(tests)
45-endif ()
46
47+# testing & coverage
48+enable_testing ()
49+add_subdirectory(tests)
50+find_package(CoverageReport)
51+ENABLE_COVERAGE_REPORT(
52+ TARGETS ${SERVICE_LIB} ${SERVICE_EXEC}
53+ TESTS ${COVERAGE_TEST_TARGETS}
54+ FILTER /usr/include ${CMAKE_BINARY_DIR}/*
55+)
56
57=== removed file 'cmake/GCov.cmake'
58--- cmake/GCov.cmake 2014-07-14 04:43:41 +0000
59+++ cmake/GCov.cmake 1970-01-01 00:00:00 +0000
60@@ -1,51 +0,0 @@
61-if (CMAKE_BUILD_TYPE MATCHES coverage)
62- set(GCOV_FLAGS "${GCOV_FLAGS} --coverage")
63- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}")
64- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}")
65- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}")
66- set(GCOV_LIBS ${GCOV_LIBS} gcov)
67-
68- find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
69- if (NOT GCOVR_EXECUTABLE)
70- message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
71- else ()
72- message(STATUS "Gcovr found, can generate XML coverage info.")
73- add_custom_target (coverage-xml
74- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
75- COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
76- --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
77- endif()
78-
79- find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
80- find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
81- if (NOT LCOV_EXECUTABLE)
82- message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
83- else ()
84- if(NOT GENHTML_EXECUTABLE)
85- message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
86- else()
87- message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
88- add_custom_target (coverage-html
89- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
90- COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose
91- COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info
92- COMMAND "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info
93- COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-lcov.info
94- COMMAND ${CMAKE_COMMAND} -E echo ""
95- COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html"
96- COMMAND ${CMAKE_COMMAND} -E echo "")
97- #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
98- #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
99- #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
100- #)
101- endif()
102- endif()
103-endif()
104-
105-
106- #$(MAKE) $(AM_MAKEFLAGS) check
107- #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info
108- #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
109- #@echo
110- #@echo " file://$(abs_top_builddir)/lcov-html/index.html"
111- #@echo
112
113=== modified file 'debian/control'
114--- debian/control 2016-07-19 10:25:12 +0000
115+++ debian/control 2017-02-07 20:08:15 +0000
116@@ -3,6 +3,9 @@
117 Priority: optional
118 Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
119 Build-Depends: cmake,
120+ cmake-extras (>= 0.10),
121+ gcovr,
122+ lcov,
123 libnotify-dev (>= 0.7.6),
124 libglib2.0-dev (>= 2.36),
125 libgudev-1.0-dev,
126@@ -15,7 +18,7 @@
127 dh-translations,
128 intltool,
129 # for tests
130- libgtest-dev,
131+ googletest | google-mock,
132 python3-dbusmock,
133 dbus-test-runner,
134 libdbustest1-dev,
135
136=== modified file 'tests/CMakeLists.txt'
137--- tests/CMakeLists.txt 2016-05-16 17:59:03 +0000
138+++ tests/CMakeLists.txt 2017-02-07 20:08:15 +0000
139@@ -1,9 +1,5 @@
140-# build libgtest
141-add_library (gtest STATIC
142- ${GTEST_SOURCE_DIR}/gtest-all.cc
143- ${GTEST_SOURCE_DIR}/gtest_main.cc)
144-set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR})
145-set_target_properties (gtest PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -w)
146+find_package(GMock)
147+include_directories(${GMOCK_INCLUDE_DIRS})
148
149 # dbustest
150 pkg_check_modules(DBUSTEST REQUIRED
151@@ -47,11 +43,17 @@
152
153 function(add_test_by_name name)
154 set (TEST_NAME ${name})
155+ set (COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME} PARENT_SCOPE)
156 add_executable (${TEST_NAME} ${TEST_NAME}.cc gschemas.compiled)
157 add_test (${TEST_NAME} ${TEST_NAME})
158 add_dependencies (${TEST_NAME} ${SERVICE_LIB})
159- target_link_libraries (${TEST_NAME} ${SERVICE_LIB} gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
160+ target_link_libraries (${TEST_NAME} ${SERVICE_LIB} ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GMOCK_LIBRARIES})
161 endfunction()
162 add_test_by_name(test-notify)
163 add_test(NAME dear-reader-the-next-test-takes-80-seconds COMMAND true)
164 add_test_by_name(test-device)
165+
166+set(COVERAGE_TEST_TARGETS
167+ ${COVERAGE_TEST_TARGETS}
168+ PARENT_SCOPE
169+)
170
171=== removed file 'tests/Makefile.am.strings'
172--- tests/Makefile.am.strings 2012-05-24 14:49:30 +0000
173+++ tests/Makefile.am.strings 1970-01-01 00:00:00 +0000
174@@ -1,38 +0,0 @@
175-TESTS += \
176- test-ellipsis \
177- test-space-ellipsis \
178- test-ascii-quotes
179-
180-#####
181-# Tests for there being proper ellipsis instead of three periods in a row
182-#####
183-test-ellipsis: $(top_srcdir)/po
184- @echo "#!/bin/bash" > $@
185- @echo "(cd $(top_srcdir)/po && make $(GETTEXT_PACKAGE).pot)" >> $@
186- @echo "grep -c -e \"^msgid.*\.\.\.\\\"\" $(top_srcdir)/po/$(GETTEXT_PACKAGE).pot > /dev/null && echo \"Ellipsis found in user visible strings\" >&2 && exit 1" >> $@
187- @echo "exit 0" >> $@
188- @chmod +x $@
189-
190-#####
191-# Tests for there being a space before an ellipsis
192-#####
193-test-space-ellipsis: $(top_srcdir)/po
194- @echo "#!/bin/bash" > $@
195- @echo "(cd $(top_srcdir)/po && make $(GETTEXT_PACKAGE).pot)" >> $@
196- @echo "grep -c -e \"^msgid.* …\\\"\" $(top_srcdir)/po/$(GETTEXT_PACKAGE).pot > /dev/null && echo \"Space before ellipsis found in user visible strings\" >&2 && exit 1" >> $@
197- @echo "exit 0" >> $@
198- @chmod +x $@
199-
200-#####
201-# Tests for ASCII quote types
202-#####
203-test-ascii-quotes: $(top_srcdir)/po
204- @echo "#!/bin/bash" > $@
205- @echo "(cd $(top_srcdir)/po && make $(GETTEXT_PACKAGE).pot)" >> $@
206- @echo "grep -c -e \"^msgid \\\".*'.*\\\"\" $(top_srcdir)/po/$(GETTEXT_PACKAGE).pot > /dev/null && echo \"ASCII apostrophy found in user visible strings\" >&2 && exit 1" >> $@
207- @echo "grep -c -e \"^msgid \\\".*\\\".*\\\"\" $(top_srcdir)/po/$(GETTEXT_PACKAGE).pot > /dev/null && echo \"ASCII quote found in user visible strings\" >&2 && exit 1" >> $@
208- @echo "grep -c -e \"^msgid \\\".*\\\`.*\\\"\" $(top_srcdir)/po/$(GETTEXT_PACKAGE).pot > /dev/null && echo \"ASCII backtick found in user visible strings\" >&2 && exit 1" >> $@
209- @echo "exit 0" >> $@
210- @chmod +x $@
211-
212-CLEANFILES += $(TESTS)

Subscribers

People subscribed via source and target branches