Merge lp:~allanlesage/evolution-indicator/TDD into lp:evolution-indicator

Proposed by Allan LeSage
Status: Needs review
Proposed branch: lp:~allanlesage/evolution-indicator/TDD
Merge into: lp:evolution-indicator
Diff against target: 196 lines (+153/-1)
5 files modified
Makefile.am (+2/-0)
Makefile.am.coverage (+48/-0)
configure.ac (+12/-0)
m4/gcov.m4 (+86/-0)
src/Makefile.am (+5/-1)
To merge this branch: bzr merge lp:~allanlesage/evolution-indicator/TDD
Reviewer Review Type Date Requested Status
Charles Kerr Pending
Review via email: mp+108050@code.launchpad.net

Description of the change

Here I have given the gcov treatment to evolution-indicator, so that we can measure its code-coverage. Note that `make coverage-html` will fail at the moment as there are no tests.

To post a comment you must log in.

Unmerged revisions

87. By Allan LeSage

Added coverage instrumentation.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2010-10-12 16:33:57 +0000
+++ Makefile.am 2012-05-30 20:36:18 +0000
@@ -15,3 +15,5 @@
15 else \15 else \
16 echo Failed to generate ChangeLog >&2; \16 echo Failed to generate ChangeLog >&2; \
17 fi17 fi
18
19include $(top_srcdir)/Makefile.am.coverage
1820
=== added file 'Makefile.am.coverage'
--- Makefile.am.coverage 1970-01-01 00:00:00 +0000
+++ Makefile.am.coverage 2012-05-30 20:36:18 +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: clean-gcda
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: clean-gcda
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) -x -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
=== modified file 'configure.ac'
--- configure.ac 2012-05-25 21:05:11 +0000
+++ configure.ac 2012-05-30 20:36:18 +0000
@@ -44,6 +44,18 @@
44fi44fi
45AC_SUBST(EVO_PLUGIN_DIR)45AC_SUBST(EVO_PLUGIN_DIR)
4646
47dnl ******************************
48dnl gcov coverage reporting
49dnl ******************************
50
51m4_include([m4/gcov.m4])
52AC_TDD_GCOV
53AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
54AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
55AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
56AC_SUBST(COVERAGE_CFLAGS)
57AC_SUBST(COVERAGE_CXXFLAGS)
58AC_SUBST(COVERAGE_LDFLAGS)
4759
48dnl ******************************60dnl ******************************
49dnl i18n61dnl i18n
5062
=== added directory 'm4'
=== added file 'm4/gcov.m4'
--- m4/gcov.m4 1970-01-01 00:00:00 +0000
+++ m4/gcov.m4 2012-05-30 20:36:18 +0000
@@ -0,0 +1,86 @@
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 if test "x$use_gcov" = "xyes"; then
17 # we need gcc:
18 if test "$GCC" != "yes"; then
19 AC_MSG_ERROR([GCC is required for --enable-gcov])
20 fi
21
22 # Check if ccache is being used
23 AC_CHECK_PROG(SHTOOL, shtool, shtool)
24 case `$SHTOOL path $CC` in
25 *ccache*[)] gcc_ccache=yes;;
26 *[)] gcc_ccache=no;;
27 esac
28
29 if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
30 AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
31 fi
32
33 lcov_version_list="1.6 1.7 1.8 1.9"
34 AC_CHECK_PROG(LCOV, lcov, lcov)
35 AC_CHECK_PROG(GENHTML, genhtml, genhtml)
36
37 if test "$LCOV"; then
38 AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
39 glib_cv_lcov_version=invalid
40 lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
41 for lcov_check_version in $lcov_version_list; do
42 if test "$lcov_version" = "$lcov_check_version"; then
43 glib_cv_lcov_version="$lcov_check_version (ok)"
44 fi
45 done
46 ])
47 else
48 lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
49 AC_MSG_ERROR([$lcov_msg])
50 fi
51
52 case $glib_cv_lcov_version in
53 ""|invalid[)]
54 lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
55 AC_MSG_ERROR([$lcov_msg])
56 LCOV="exit 0;"
57 ;;
58 esac
59
60 if test -z "$GENHTML"; then
61 AC_MSG_ERROR([Could not find genhtml from the lcov package])
62 fi
63
64 ac_cv_check_gcov=yes
65 ac_cv_check_lcov=yes
66
67 # Remove all optimization flags from CFLAGS
68 changequote({,})
69 CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
70 changequote([,])
71
72 # Add the special gcc flags
73 COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
74 COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
75 COVERAGE_LDFLAGS="-lgcov"
76
77 # Check availability of gcovr
78 AC_CHECK_PROG(GCOVR, gcovr, gcovr)
79 if test -z "$GCOVR"; then
80 ac_cv_check_gcovr=no
81 else
82 ac_cv_check_gcovr=yes
83 fi
84
85fi
86]) # AC_TDD_GCOV
087
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2011-09-09 08:45:39 +0000
+++ src/Makefile.am 2012-05-30 20:36:18 +0000
@@ -11,9 +11,13 @@
11 xutils.c \11 xutils.c \
12 xutils.h12 xutils.h
1313
14liborg_freedesktop_evolution_indicator_la_CFLAGS = \
15 $(COVERAGE_CFLAGS)
16
14liborg_freedesktop_evolution_indicator_la_LDFLAGS = \17liborg_freedesktop_evolution_indicator_la_LDFLAGS = \
15 -module -avoid-version \18 -module -avoid-version \
16 $(DEPS_LIBS)19 $(DEPS_LIBS) \
20 $(COVERAGE_LDFLAGS)
1721
18org-freedesktop-evolution-indicator.eplug.in : org-freedesktop-evolution-indicator.eplug.xml22org-freedesktop-evolution-indicator.eplug.in : org-freedesktop-evolution-indicator.eplug.xml
19 LC_ALL=C $(INTLTOOL_MERGE) -x -u /tmp/notthere $< $@23 LC_ALL=C $(INTLTOOL_MERGE) -x -u /tmp/notthere $< $@

Subscribers

People subscribed via source and target branches