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

Proposed by dobey on 2017-02-07
Status: Merged
Approved by: dobey on 2017-02-10
Approved revision: 308
Merged at revision: 306
Proposed branch: lp:~dobey/indicator-power/fix-coverage
Merge into: lp:indicator-power
Prerequisite: lp:~dobey/indicator-power/fix-gtest
Diff against target: 174 lines (+21/-72)
5 files modified
CMakeLists.txt (+9/-17)
cmake/GCov.cmake (+0/-51)
debian/control (+2/-0)
src/CMakeLists.txt (+3/-3)
tests/CMakeLists.txt (+7/-1)
To merge this branch: bzr merge lp:~dobey/indicator-power/fix-coverage
Reviewer Review Type Date Requested Status
Pete Woods (community) Approve on 2017-02-10
Ted Gould (community) 2017-02-07 Needs Information on 2017-02-07
unity-api-1-bot continuous-integration Approve on 2017-02-07
Review via email: mp+316621@code.launchpad.net

Commit message

Use coverage support from cmake-extras.

To post a comment you must log in.
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:306
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-power-ci/8/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1624
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1631
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1409
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1409/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1409
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1409/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1409
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1409/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1409
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1409/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1409
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1409/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1409
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1409/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
307. By dobey on 2017-02-07

Remove usage of extra GCOV variables.

unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:307
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-power-ci/10/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1627
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1634
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1413
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1413/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1413
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1413/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1413
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1413/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1413
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1413/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1413
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1413/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1413
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1413/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Ted Gould (ted) :
review: Needs Information
dobey (dobey) :
Pete Woods (pete-woods) :
review: Needs Fixing
308. By dobey on 2017-02-10

Remove hard-coded -g compiler flag.

Pete Woods (pete-woods) :
review: Approve

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 2017-02-10 16:21:31 +0000
3+++ CMakeLists.txt 2017-02-10 16:21:32 +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,19 +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- enable_testing ()
31- if (${enable_lcov})
32- include(GCov)
33- endif ()
34-endif ()
35-
36 # actually build things
37 add_subdirectory(src)
38 add_subdirectory(data)
39 add_subdirectory(po)
40-if (${enable_tests})
41- add_subdirectory(tests)
42-endif ()
43
44+# testing & coverage
45+enable_testing ()
46+add_subdirectory(tests)
47+find_package(CoverageReport)
48+ENABLE_COVERAGE_REPORT(
49+ TARGETS ${SERVICE_LIB} ${SERVICE_EXEC}
50+ TESTS ${COVERAGE_TEST_TARGETS}
51+ FILTER /usr/include ${CMAKE_BINARY_DIR}/*
52+)
53
54=== removed file 'cmake/GCov.cmake'
55--- cmake/GCov.cmake 2014-07-14 04:43:41 +0000
56+++ cmake/GCov.cmake 1970-01-01 00:00:00 +0000
57@@ -1,51 +0,0 @@
58-if (CMAKE_BUILD_TYPE MATCHES coverage)
59- set(GCOV_FLAGS "${GCOV_FLAGS} --coverage")
60- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}")
61- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}")
62- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}")
63- set(GCOV_LIBS ${GCOV_LIBS} gcov)
64-
65- find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
66- if (NOT GCOVR_EXECUTABLE)
67- message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
68- else ()
69- message(STATUS "Gcovr found, can generate XML coverage info.")
70- add_custom_target (coverage-xml
71- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
72- COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
73- --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
74- endif()
75-
76- find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
77- find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
78- if (NOT LCOV_EXECUTABLE)
79- message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
80- else ()
81- if(NOT GENHTML_EXECUTABLE)
82- message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
83- else()
84- message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
85- add_custom_target (coverage-html
86- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
87- COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose
88- COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info
89- COMMAND "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info
90- COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-lcov.info
91- COMMAND ${CMAKE_COMMAND} -E echo ""
92- COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html"
93- COMMAND ${CMAKE_COMMAND} -E echo "")
94- #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
95- #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
96- #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
97- #)
98- endif()
99- endif()
100-endif()
101-
102-
103- #$(MAKE) $(AM_MAKEFLAGS) check
104- #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info
105- #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
106- #@echo
107- #@echo " file://$(abs_top_builddir)/lcov-html/index.html"
108- #@echo
109
110=== modified file 'debian/control'
111--- debian/control 2017-02-10 16:21:31 +0000
112+++ debian/control 2017-02-10 16:21:32 +0000
113@@ -4,6 +4,8 @@
114 Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
115 Build-Depends: cmake,
116 cmake-extras (>= 0.10),
117+ gcovr,
118+ lcov,
119 libnotify-dev (>= 0.7.6),
120 libglib2.0-dev (>= 2.36),
121 libgudev-1.0-dev,
122
123=== modified file 'src/CMakeLists.txt'
124--- src/CMakeLists.txt 2016-05-16 17:59:03 +0000
125+++ src/CMakeLists.txt 2017-02-10 16:21:32 +0000
126@@ -42,7 +42,7 @@
127 set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-assign-enum") # GParamFlags
128 set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-switch-enum")
129 set_source_files_properties(${SERVICE_MANUAL_SOURCES}
130- PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} ${GCOV_FLAGS} -g -std=c99")
131+ PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -std=c99")
132
133 # the service library for tests to link against (basically, everything except main())
134 add_library(${SERVICE_LIB} STATIC ${SERVICE_MANUAL_SOURCES} ${SERVICE_GENERATED_SOURCES})
135@@ -51,7 +51,7 @@
136
137 # the executable: lib + main()
138 add_executable (${SERVICE_EXEC} main.c)
139-set_source_files_properties(${SERVICE_SOURCES} main.c PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -g -std=c99")
140-target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${GCOV_LIBS})
141+set_source_files_properties(${SERVICE_SOURCES} main.c PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -std=c99")
142+target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES})
143 install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})
144
145
146=== modified file 'tests/CMakeLists.txt'
147--- tests/CMakeLists.txt 2017-02-10 16:21:31 +0000
148+++ tests/CMakeLists.txt 2017-02-10 16:21:32 +0000
149@@ -7,7 +7,7 @@
150 include_directories (SYSTEM ${DBUSTEST_INCLUDE_DIRS})
151
152 # add warnings
153-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${C_WARNING_ARGS}")
154+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_WARNING_ARGS}")
155 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-global-constructors") # Google Test
156
157 # build the necessary schemas
158@@ -43,6 +43,7 @@
159
160 function(add_test_by_name name)
161 set (TEST_NAME ${name})
162+ set (COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME} PARENT_SCOPE)
163 add_executable (${TEST_NAME} ${TEST_NAME}.cc gschemas.compiled)
164 add_test (${TEST_NAME} ${TEST_NAME})
165 add_dependencies (${TEST_NAME} ${SERVICE_LIB})
166@@ -51,3 +52,8 @@
167 add_test_by_name(test-notify)
168 add_test(NAME dear-reader-the-next-test-takes-80-seconds COMMAND true)
169 add_test_by_name(test-device)
170+
171+set(COVERAGE_TEST_TARGETS
172+ ${COVERAGE_TEST_TARGETS}
173+ PARENT_SCOPE
174+)

Subscribers

People subscribed via source and target branches