Merge lp:~allanlesage/libcolumbus/enable-coverage-option into lp:libcolumbus

Proposed by Allan LeSage
Status: Approved
Approved by: Jussi Pakkanen
Approved revision: 470
Proposed branch: lp:~allanlesage/libcolumbus/enable-coverage-option
Merge into: lp:libcolumbus
Diff against target: 97 lines (+18/-36)
3 files modified
CMakeLists.txt (+6/-1)
cmake/coverage.cmake (+0/-34)
readme.txt (+12/-1)
To merge this branch: bzr merge lp:~allanlesage/libcolumbus/enable-coverage-option
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+218875@code.launchpad.net

Description of the change

Demonstrate use of our standard coverage-report-generating CMake files for Jussi's review, specifically using the coverage as an option (instead of build type).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Looking good. A few things to note:

This sets --coverage to CMAKE_CXX_FLAGS but line 108 has SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE). The latter is probably leftovers from the old way?

Currently the flags are set at the top level CMakeLists.txt. It would be better if this was moved into the coverage module itself. Thus the only thing you would need to do to add coverage to a new target is this:

if(enable_coverage)
 include(cmake/EnableCoverageReport.cmake)
 ENABLE_COVERAGE_REPORT(TARGETS ${COL_LIB_BASENAME} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* {CMAKE_BINARY_DIR}/*)
endif()

If we want this to be generally usable then the coverage macro should only add coverage flags to those languages that are enabled. Something along the lines of:

get_property(GLOBAL langlist LANGUAGES)
list(FIND langlist C index)
if(NOT ${index] EQUAL -1)
  set flags for plain c
endif()
... then the same for C++ etc

review: Needs Fixing
468. By Allan LeSage

Remove duplicate setting of linker and compilation flags for coverage.

Revision history for this message
Allan LeSage (allanlesage) wrote :

Removed those extraneous settings of link and compilation flags for coverage. Jussi I see the wisdom of your second point re: adding flags only for affected languages--what do you think of l. 113-14, where we're just adding the flags to COMPILE_FLAGS and LINK_FLAGS, presumably this adequately serves the need?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Adding compiler flags via the target property is good.

There is the issue, though, that the code is lgpl3, which might mean we can't put it in our projects without a CLA. In addition it prevents submitting this upstream as CMake is BSD licensed.

review: Needs Information
Revision history for this message
Allan LeSage (allanlesage) wrote :

In Malta we've packaged a cmake-extras set of modules which includes the coverage file, this should satisfy our licensing needs, will update when that has landed.

469. By Allan LeSage

Switch to installed EnableCoverageReport macro from cmake-extras.

Revision history for this message
Allan LeSage (allanlesage) wrote :

Now that cmake-extras has landed in utopic universe, this MP becomes much simpler :) --I suppose the last thing is to decide whether or not to debian/control include cmake-extras or to ignore the error of not being able to import EnableCoverageReport?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

AFAIK we can't build-dep on cmake-extras as it is not in main (yet). We have two build types we need to support:

- regular package builds without coverage
- coverage builds that don't produce packages (or do they? I don't really know)

Not having cmake-extras in build-deps is good for the first case as it minimizes dependencies. But that would mean that the environment setup of coverage builds needs an extra hook to install it before building. Maybe it already has this? It does need gcov + genhtml installed at least and they are not in build-deps.

As far as the CMake side is concerned, I recommend doing this in all our packages:

option(enable_coverage "Build with coverage flags." OFF)
if(enable_coverage)
 include(coverage file)
 ENABLE_COVERAGE_REPORT(TARGETS your targets here)
endif()

Thus by default it is off and does not require cmake-extras, but if you enable it manually, it is loaded and will produce an error if missing.

Revision history for this message
Allan LeSage (allanlesage) wrote :

Ok I think we'll leave as-is, then :) --thanks Jussi for your reviews.

Revision history for this message
Allan LeSage (allanlesage) wrote :

Bump!

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

If we want to merge this then debian/control needs to add cmake-extras to the build deps. But more importantly cmake-extras needs to get into main, as libcolumbus may not build-depend on packages in universe.

review: Needs Fixing
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Or is this handled by the coverage build environment already?

Revision history for this message
Allan LeSage (allanlesage) wrote :

I'll add a note to the readme.txt, need to verify with an utopic build--but yes the -Denable_coverage=ON option *should* work. I recall discussing this in Malta however briefly: I'd be happy to pursue getting cmake-extras into main but I think the optional nature of this option makes it optional, no? Lastly, do we want to call this 'coverage'? (As opposed to 'enable_coverage'?)

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

This will work if cmake-extras is installed in the system doing the build. In pbuilder and the like this won't be the case because only the packages listed in build dependencies are installed. Someone needs to special case that package in (as it can't be in build deps for the abovementioned reasons).

I don't have an opinion on the name, really. Either one is fine.

470. By Allan LeSage

Explain coverage in readme.txt.

Revision history for this message
Allan LeSage (allanlesage) wrote :

Sorry for the delay in replying.

Jussi you mention the special case of installing cmake-extras for testing builds--indeed this is handled by the Jenkins builders presently (and we'll have to carry it forward to the ci-airline system).

I've updated the readme, please review for style :) .

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Looks good to me.

review: Approve

Unmerged revisions

470. By Allan LeSage

Explain coverage in readme.txt.

469. By Allan LeSage

Switch to installed EnableCoverageReport macro from cmake-extras.

468. By Allan LeSage

Remove duplicate setting of linker and compilation flags for coverage.

467. By Allan LeSage

Oops remove existing version of coverage.cmake.

466. By Allan LeSage

Demonstrate coverage option with standard tooling for Jussi's review.

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 2014-03-11 14:02:22 +0000
3+++ CMakeLists.txt 2014-07-23 01:12:43 +0000
4@@ -11,6 +11,7 @@
5 option(debug_messages "Print debug messages.")
6 option(full_unicode "Enable full Unicode support (takes lots of memory).")
7 option(use_python2 "Build Python bindings against Python 2 (UNSUPPORTED)." OFF)
8+option(enable_coverage "Add coverage targets.")
9
10 if(use_python2)
11 message(WARNING "Python 2 bindings are NOT SUPPORTED! If they break, you get to keep both pieces.")
12@@ -19,7 +20,6 @@
13 include(FindPkgConfig)
14 include(cmake/pch.cmake)
15 include(cmake/python.cmake)
16-include(cmake/coverage.cmake)
17
18 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wextra")
19 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra")
20@@ -123,6 +123,11 @@
21 add_subdirectory(python)
22 endif()
23
24+if(enable_coverage)
25+ include(EnableCoverageReport)
26+ ENABLE_COVERAGE_REPORT(TARGETS ${COL_LIB_BASENAME} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*)
27+endif()
28+
29 if(${enable_tests})
30 enable_testing()
31 add_subdirectory(test)
32
33=== removed file 'cmake/coverage.cmake'
34--- cmake/coverage.cmake 2013-02-15 15:25:59 +0000
35+++ cmake/coverage.cmake 1970-01-01 00:00:00 +0000
36@@ -1,34 +0,0 @@
37-if (CMAKE_BUILD_TYPE MATCHES coverage)
38- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
39- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
40- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage")
41- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
42-
43- find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
44- if (NOT GCOVR_EXECUTABLE)
45- message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
46- else ()
47- message(STATUS "Gcovr found, can generate XML coverage info.")
48- add_custom_target (coverage-xml
49- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
50- COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
51- --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
52- endif()
53-
54- find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
55- find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
56- if (NOT LCOV_EXECUTABLE)
57- message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
58- else ()
59- if(NOT GENHTML_EXECUTABLE)
60- message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
61- else()
62- message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
63- add_custom_target (coverage-html
64- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
65- COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
66- COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
67- )
68- endif()
69- endif()
70-endif()
71
72=== modified file 'readme.txt'
73--- readme.txt 2012-05-23 07:57:25 +0000
74+++ readme.txt 2014-07-23 01:12:43 +0000
75@@ -1,6 +1,6 @@
76 Columbus - a library for fast error-tolerant searching
77
78-(C) 2012 Canonical ltd
79+(C) 2012, 2014 Canonical ltd
80
81
82 Compiling
83@@ -25,3 +25,14 @@
84 There are additional scalability tests that need to be enabled separately,
85 since they take quite a lot of time to run. They are enabled in the same way
86 as regular tests.
87+
88+To view test coverage results, first apt-get cmake-extras (under ubuntu),
89+then make, enabling the coverage option, run the tests, and generate the
90+report:
91+
92+cd build
93+cmake -Denable_coverage=ON ..
94+make
95+make test
96+make coverage
97+firefox coveragereport/index.html

Subscribers

People subscribed via source and target branches

to all changes: