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

Proposed by dobey
Status: Merged
Approved by: dobey
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
Ted Gould (community) Needs Information
unity-api-1-bot continuous-integration Approve
Review via email: mp+316621@code.launchpad.net

Commit message

Use coverage support from cmake-extras.

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: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

Remove usage of extra GCOV variables.

Revision history for this message
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)
Revision history for this message
Ted Gould (ted) :
review: Needs Information
Revision history for this message
dobey (dobey) :
Revision history for this message
Pete Woods (pete-woods) :
review: Needs Fixing
308. By dobey

Remove hard-coded -g compiler flag.

Revision history for this message
Pete Woods (pete-woods) :
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 2017-02-10 16:21:31 +0000
+++ CMakeLists.txt 2017-02-10 16:21:32 +0000
@@ -13,9 +13,6 @@
13 -DLOW_BATTERY_SOUND="Low battery.ogg"13 -DLOW_BATTERY_SOUND="Low battery.ogg"
14)14)
1515
16option (enable_tests "Build the package's automatic tests." ON)
17option (enable_lcov "Generate lcov code coverage reports." ON)
18
19set(SERVICE_LIB "indicatorpowerservice")16set(SERVICE_LIB "indicatorpowerservice")
20set(SERVICE_EXEC "indicator-power-service")17set(SERVICE_EXEC "indicator-power-service")
21add_definitions(-DSERVICE_EXEC="${SERVICE_EXEC}")18add_definitions(-DSERVICE_EXEC="${SERVICE_EXEC}")
@@ -59,9 +56,6 @@
59 COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz56 COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
60 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})57 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
6158
62add_custom_target (clean-coverage
63 COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
64
65add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr59add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
66 ${CMAKE_SOURCE_DIR}/src60 ${CMAKE_SOURCE_DIR}/src
67 ${CMAKE_SOURCE_DIR}/tests)61 ${CMAKE_SOURCE_DIR}/tests)
@@ -83,19 +77,17 @@
83include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)77include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
84include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)78include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
8579
86# testing & coverage
87if (${enable_tests})
88 enable_testing ()
89 if (${enable_lcov})
90 include(GCov)
91 endif ()
92endif ()
93
94# actually build things80# actually build things
95add_subdirectory(src)81add_subdirectory(src)
96add_subdirectory(data)82add_subdirectory(data)
97add_subdirectory(po)83add_subdirectory(po)
98if (${enable_tests})
99 add_subdirectory(tests)
100endif ()
10184
85# testing & coverage
86enable_testing ()
87add_subdirectory(tests)
88find_package(CoverageReport)
89ENABLE_COVERAGE_REPORT(
90 TARGETS ${SERVICE_LIB} ${SERVICE_EXEC}
91 TESTS ${COVERAGE_TEST_TARGETS}
92 FILTER /usr/include ${CMAKE_BINARY_DIR}/*
93)
10294
=== removed file 'cmake/GCov.cmake'
--- cmake/GCov.cmake 2014-07-14 04:43:41 +0000
+++ cmake/GCov.cmake 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1if (CMAKE_BUILD_TYPE MATCHES coverage)
2 set(GCOV_FLAGS "${GCOV_FLAGS} --coverage")
3 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}")
4 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}")
5 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}")
6 set(GCOV_LIBS ${GCOV_LIBS} gcov)
7
8 find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
9 if (NOT GCOVR_EXECUTABLE)
10 message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
11 else ()
12 message(STATUS "Gcovr found, can generate XML coverage info.")
13 add_custom_target (coverage-xml
14 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
15 COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
16 --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
17 endif()
18
19 find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
20 find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
21 if (NOT LCOV_EXECUTABLE)
22 message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
23 else ()
24 if(NOT GENHTML_EXECUTABLE)
25 message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
26 else()
27 message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
28 add_custom_target (coverage-html
29 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
30 COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose
31 COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info
32 COMMAND "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info
33 COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-lcov.info
34 COMMAND ${CMAKE_COMMAND} -E echo ""
35 COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html"
36 COMMAND ${CMAKE_COMMAND} -E echo "")
37 #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
38 #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
39 #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
40 #)
41 endif()
42 endif()
43endif()
44
45
46 #$(MAKE) $(AM_MAKEFLAGS) check
47 #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info
48 #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
49 #@echo
50 #@echo " file://$(abs_top_builddir)/lcov-html/index.html"
51 #@echo
520
=== modified file 'debian/control'
--- debian/control 2017-02-10 16:21:31 +0000
+++ debian/control 2017-02-10 16:21:32 +0000
@@ -4,6 +4,8 @@
4Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>4Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5Build-Depends: cmake,5Build-Depends: cmake,
6 cmake-extras (>= 0.10),6 cmake-extras (>= 0.10),
7 gcovr,
8 lcov,
7 libnotify-dev (>= 0.7.6),9 libnotify-dev (>= 0.7.6),
8 libglib2.0-dev (>= 2.36),10 libglib2.0-dev (>= 2.36),
9 libgudev-1.0-dev,11 libgudev-1.0-dev,
1012
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-05-16 17:59:03 +0000
+++ src/CMakeLists.txt 2017-02-10 16:21:32 +0000
@@ -42,7 +42,7 @@
42set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-assign-enum") # GParamFlags42set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-assign-enum") # GParamFlags
43set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-switch-enum")43set(C_WARNING_ARGS "${C_WARNING_ARGS} -Wno-switch-enum")
44set_source_files_properties(${SERVICE_MANUAL_SOURCES}44set_source_files_properties(${SERVICE_MANUAL_SOURCES}
45 PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} ${GCOV_FLAGS} -g -std=c99")45 PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -std=c99")
4646
47# the service library for tests to link against (basically, everything except main())47# the service library for tests to link against (basically, everything except main())
48add_library(${SERVICE_LIB} STATIC ${SERVICE_MANUAL_SOURCES} ${SERVICE_GENERATED_SOURCES})48add_library(${SERVICE_LIB} STATIC ${SERVICE_MANUAL_SOURCES} ${SERVICE_GENERATED_SOURCES})
@@ -51,7 +51,7 @@
5151
52# the executable: lib + main()52# the executable: lib + main()
53add_executable (${SERVICE_EXEC} main.c)53add_executable (${SERVICE_EXEC} main.c)
54set_source_files_properties(${SERVICE_SOURCES} main.c PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -g -std=c99")54set_source_files_properties(${SERVICE_SOURCES} main.c PROPERTIES COMPILE_FLAGS "${C_WARNING_ARGS} -std=c99")
55target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${GCOV_LIBS})55target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES})
56install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})56install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})
5757
5858
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2017-02-10 16:21:31 +0000
+++ tests/CMakeLists.txt 2017-02-10 16:21:32 +0000
@@ -7,7 +7,7 @@
7include_directories (SYSTEM ${DBUSTEST_INCLUDE_DIRS})7include_directories (SYSTEM ${DBUSTEST_INCLUDE_DIRS})
88
9# add warnings9# add warnings
10set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${C_WARNING_ARGS}")10set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_WARNING_ARGS}")
11set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-global-constructors") # Google Test11set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-global-constructors") # Google Test
1212
13# build the necessary schemas13# build the necessary schemas
@@ -43,6 +43,7 @@
4343
44function(add_test_by_name name)44function(add_test_by_name name)
45 set (TEST_NAME ${name})45 set (TEST_NAME ${name})
46 set (COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME} PARENT_SCOPE)
46 add_executable (${TEST_NAME} ${TEST_NAME}.cc gschemas.compiled)47 add_executable (${TEST_NAME} ${TEST_NAME}.cc gschemas.compiled)
47 add_test (${TEST_NAME} ${TEST_NAME})48 add_test (${TEST_NAME} ${TEST_NAME})
48 add_dependencies (${TEST_NAME} ${SERVICE_LIB})49 add_dependencies (${TEST_NAME} ${SERVICE_LIB})
@@ -51,3 +52,8 @@
51add_test_by_name(test-notify)52add_test_by_name(test-notify)
52add_test(NAME dear-reader-the-next-test-takes-80-seconds COMMAND true)53add_test(NAME dear-reader-the-next-test-takes-80-seconds COMMAND true)
53add_test_by_name(test-device)54add_test_by_name(test-device)
55
56set(COVERAGE_TEST_TARGETS
57 ${COVERAGE_TEST_TARGETS}
58 PARENT_SCOPE
59)

Subscribers

People subscribed via source and target branches