dee

Merge lp:~fginther/dee/add-code-coverage into lp:dee

Proposed by Francis Ginther
Status: Merged
Approved by: Michal Hruby
Approved revision: 396
Merged at revision: 395
Proposed branch: lp:~fginther/dee/add-code-coverage
Merge into: lp:dee
Diff against target: 211 lines (+156/-2)
5 files modified
Makefile.am (+4/-0)
Makefile.am.coverage (+48/-0)
build/autotools/gcov.m4 (+89/-0)
configure.ac (+11/-0)
src/Makefile.am (+4/-2)
To merge this branch: bzr merge lp:~fginther/dee/add-code-coverage
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+139586@code.launchpad.net

Commit message

Add code coverage reporting with coverage-html and coverage-gcovr targets.

Coverage reporting can be enabled with --enable-gcov.

Description of the change

Add code coverage reporting with coverage-html and coverage-gcovr targets.

Coverage reporting can be enabled with --enable-gcov.

Testing:
 - Built coverage targets and verified results.
 - Built in pbuilder chroot with hooks to enable gcovr report.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~fginther/dee/add-code-coverage updated
396. By Francis Ginther

Fixed building for non-srcdir builds and cleaned up a warning message.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

I've fixed the issues with non-srcdir builds:

# mkdir builddir;cd builddir; ../autogen.sh; make

Retested with local builds, pbuilder and jenkins (the -ci run above includes coverage data).

Revision history for this message
Michal Hruby (mhr3) wrote :

Seems to work fine now (minus some warnings about double PHONY declaration)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2012-08-10 10:56:44 +0000
+++ Makefile.am 2012-12-13 21:16:19 +0000
@@ -1,3 +1,7 @@
1ACLOCAL_AMFLAGS = -I build/autotools
2
3include $(top_srcdir)/Makefile.am.coverage
4
1SUBDIRS = build src doc examples tools vapi bindings5SUBDIRS = build src doc examples tools vapi bindings
26
3pkgconfigdir = $(libdir)/pkgconfig7pkgconfigdir = $(libdir)/pkgconfig
48
=== added file 'Makefile.am.coverage'
--- Makefile.am.coverage 1970-01-01 00:00:00 +0000
+++ Makefile.am.coverage 2012-12-13 21:16:19 +0000
@@ -0,0 +1,48 @@
1
2# Coverage targets
3
4.PHONY: clean-gcno clean-gcda \
5 coverage-html generate-coverage-html clean-coverage-html \
6 coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
7
8clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
9
10if HAVE_GCOV
11
12clean-gcno:
13 @echo Removing old coverage instrumentation
14 -find -name '*.gcno' -print | xargs -r rm
15
16clean-gcda:
17 @echo Removing old coverage results
18 -find -name '*.gcda' -print | xargs -r rm
19
20coverage-html:
21 -$(MAKE) $(AM_MAKEFLAGS) -k check
22 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
23
24generate-coverage-html:
25 @echo Collecting coverage data
26 $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
27 LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
28
29clean-coverage-html: clean-gcda
30 -$(LCOV) --directory $(top_builddir) -z
31 -rm -rf coverage.info coveragereport
32
33if HAVE_GCOVR
34
35coverage-gcovr:
36 -$(MAKE) $(AM_MAKEFLAGS) -k check
37 $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
38
39generate-coverage-gcovr:
40 @echo Generating coverage GCOVR report
41 $(GCOVR) --xml -r $(top_builddir) -o $(top_builddir)/coverage.xml
42
43clean-coverage-gcovr: clean-gcda
44 -rm -rf $(top_builddir)/coverage.xml
45
46endif # HAVE_GCOVR
47
48endif # HAVE_GCOV
049
=== added file 'build/autotools/gcov.m4'
--- build/autotools/gcov.m4 1970-01-01 00:00:00 +0000
+++ build/autotools/gcov.m4 2012-12-13 21:16:19 +0000
@@ -0,0 +1,89 @@
1# Checks for existence of coverage tools:
2# * gcov
3# * lcov
4# * genhtml
5# * gcovr
6#
7# Sets ac_cv_check_gcov to yes if tooling is present
8# and reports the executables to the variables LCOV, GCOVR and GENHTML.
9AC_DEFUN([AC_TDD_GCOV],
10[
11 AC_ARG_ENABLE(gcov,
12 AS_HELP_STRING([--enable-gcov],
13 [enable coverage testing with gcov]),
14 [use_gcov=$enableval], [use_gcov=no])
15
16 AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes")
17
18 if test "x$use_gcov" = "xyes"; then
19 # we need gcc:
20 if test "$GCC" != "yes"; then
21 AC_MSG_ERROR([GCC is required for --enable-gcov])
22 fi
23
24 # Check if ccache is being used
25 AC_CHECK_PROG(SHTOOL, shtool, shtool)
26 if test "$SHTOOL"; then
27 AS_CASE([`$SHTOOL path $CC`],
28 [*ccache*], [gcc_ccache=yes],
29 [gcc_ccache=no])
30 fi
31
32 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
33 AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
34 fi
35
36 lcov_version_list="1.6 1.7 1.8 1.9"
37 AC_CHECK_PROG(LCOV, lcov, lcov)
38 AC_CHECK_PROG(GENHTML, genhtml, genhtml)
39
40 if test "$LCOV"; then
41 AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
42 glib_cv_lcov_version=invalid
43 lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
44 for lcov_check_version in $lcov_version_list; do
45 if test "$lcov_version" = "$lcov_check_version"; then
46 glib_cv_lcov_version="$lcov_check_version (ok)"
47 fi
48 done
49 ])
50 else
51 lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
52 AC_MSG_ERROR([$lcov_msg])
53 fi
54
55 case $glib_cv_lcov_version in
56 ""|invalid[)]
57 lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
58 AC_MSG_ERROR([$lcov_msg])
59 LCOV="exit 0;"
60 ;;
61 esac
62
63 if test -z "$GENHTML"; then
64 AC_MSG_ERROR([Could not find genhtml from the lcov package])
65 fi
66
67 ac_cv_check_gcov=yes
68 ac_cv_check_lcov=yes
69
70 # Remove all optimization flags from CFLAGS
71 changequote({,})
72 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
73 changequote([,])
74
75 # Add the special gcc flags
76 COVERAGE_CFLAGS="-O0 --coverage"
77 COVERAGE_CXXFLAGS="-O0 --coverage"
78 COVERAGE_LDFLAGS="-lgcov"
79
80 # Check availability of gcovr
81 AC_CHECK_PROG(GCOVR, gcovr, gcovr)
82 if test -z "$GCOVR"; then
83 ac_cv_check_gcovr=no
84 else
85 ac_cv_check_gcovr=yes
86 fi
87fi
88]) # AC_TDD_GCOV
89
090
=== modified file 'configure.ac'
--- configure.ac 2012-11-28 08:53:48 +0000
+++ configure.ac 2012-12-13 21:16:19 +0000
@@ -140,6 +140,16 @@
140140
141AM_CONDITIONAL([WANT_TESTS], [test "x$enable_tests" != "xno"])141AM_CONDITIONAL([WANT_TESTS], [test "x$enable_tests" != "xno"])
142142
143###########################
144# gcov coverage reporting
145###########################
146AC_TDD_GCOV
147AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
148AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
149AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
150AC_SUBST(COVERAGE_CFLAGS)
151AC_SUBST(COVERAGE_LDFLAGS)
152
143dnl = Check for GLib Test Extensions (GTX) ====================================153dnl = Check for GLib Test Extensions (GTX) ====================================
144AC_ARG_ENABLE([extended-tests],154AC_ARG_ENABLE([extended-tests],
145 AS_HELP_STRING([--enable-extended-tests=@<:@no/yes@:>@],[build extended test suite (requires libgtx from lp:gtx) @<:@default=no@:>@]),,155 AS_HELP_STRING([--enable-extended-tests=@<:@no/yes@:>@],[build extended test suite (requires libgtx from lp:gtx) @<:@default=no@:>@]),,
@@ -245,6 +255,7 @@
245255
246 Tests : ${enable_tests}256 Tests : ${enable_tests}
247 Extended Tests : ${enable_extended_tests}257 Extended Tests : ${enable_extended_tests}
258 Coverage : ${use_gcov}
248 Verbose logging: ${enable_trace_log}259 Verbose logging: ${enable_trace_log}
249260
250 Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS261 Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS
251262
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2012-11-28 08:53:48 +0000
+++ src/Makefile.am 2012-12-13 21:16:19 +0000
@@ -101,7 +101,8 @@
101 $(DEE_LIBS)101 $(DEE_LIBS)
102102
103libdee_1_0_la_LDFLAGS = \103libdee_1_0_la_LDFLAGS = \
104 $(DEE_LT_LDFLAGS)104 $(DEE_LT_LDFLAGS) \
105 $(COVERAGE_LDFLAGS)
105106
106libdee_1_0_la_CPPFLAGS = \107libdee_1_0_la_CPPFLAGS = \
107 -I$(srcdir) \108 -I$(srcdir) \
@@ -114,7 +115,8 @@
114 -DDEE_COMPILATION \115 -DDEE_COMPILATION \
115 $(GCC_FLAGS) \116 $(GCC_FLAGS) \
116 $(DEE_CFLAGS) \117 $(DEE_CFLAGS) \
117 $(MAINTAINER_CFLAGS)118 $(MAINTAINER_CFLAGS) \
119 $(COVERAGE_CFLAGS)
118120
119if HAVE_ICU121if HAVE_ICU
120devel_headers += dee-icu.h122devel_headers += dee-icu.h

Subscribers

People subscribed via source and target branches

to all changes: