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
1=== modified file 'Makefile.am'
2--- Makefile.am 2010-10-12 16:33:57 +0000
3+++ Makefile.am 2012-05-30 20:36:18 +0000
4@@ -15,3 +15,5 @@
5 else \
6 echo Failed to generate ChangeLog >&2; \
7 fi
8+
9+include $(top_srcdir)/Makefile.am.coverage
10
11=== added file 'Makefile.am.coverage'
12--- Makefile.am.coverage 1970-01-01 00:00:00 +0000
13+++ Makefile.am.coverage 2012-05-30 20:36:18 +0000
14@@ -0,0 +1,48 @@
15+
16+# Coverage targets
17+
18+.PHONY: clean-gcno clean-gcda \
19+ coverage-html generate-coverage-html clean-coverage-html \
20+ coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
21+
22+clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
23+
24+if HAVE_GCOV
25+
26+clean-gcno:
27+ @echo Removing old coverage instrumentation
28+ -find -name '*.gcno' -print | xargs -r rm
29+
30+clean-gcda:
31+ @echo Removing old coverage results
32+ -find -name '*.gcda' -print | xargs -r rm
33+
34+coverage-html: clean-gcda
35+ -$(MAKE) $(AM_MAKEFLAGS) -k check
36+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
37+
38+generate-coverage-html:
39+ @echo Collecting coverage data
40+ $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
41+ LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
42+
43+clean-coverage-html: clean-gcda
44+ -$(LCOV) --directory $(top_builddir) -z
45+ -rm -rf coverage.info coveragereport
46+
47+if HAVE_GCOVR
48+
49+coverage-gcovr: clean-gcda
50+ -$(MAKE) $(AM_MAKEFLAGS) -k check
51+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
52+
53+generate-coverage-gcovr:
54+ @echo Generating coverage GCOVR report
55+ $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
56+
57+clean-coverage-gcovr: clean-gcda
58+ -rm -rf $(top_builddir)/coverage.xml
59+
60+endif # HAVE_GCOVR
61+
62+endif # HAVE_GCOV
63
64=== modified file 'configure.ac'
65--- configure.ac 2012-05-25 21:05:11 +0000
66+++ configure.ac 2012-05-30 20:36:18 +0000
67@@ -44,6 +44,18 @@
68 fi
69 AC_SUBST(EVO_PLUGIN_DIR)
70
71+dnl ******************************
72+dnl gcov coverage reporting
73+dnl ******************************
74+
75+m4_include([m4/gcov.m4])
76+AC_TDD_GCOV
77+AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
78+AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
79+AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
80+AC_SUBST(COVERAGE_CFLAGS)
81+AC_SUBST(COVERAGE_CXXFLAGS)
82+AC_SUBST(COVERAGE_LDFLAGS)
83
84 dnl ******************************
85 dnl i18n
86
87=== added directory 'm4'
88=== added file 'm4/gcov.m4'
89--- m4/gcov.m4 1970-01-01 00:00:00 +0000
90+++ m4/gcov.m4 2012-05-30 20:36:18 +0000
91@@ -0,0 +1,86 @@
92+# Checks for existence of coverage tools:
93+# * gcov
94+# * lcov
95+# * genhtml
96+# * gcovr
97+#
98+# Sets ac_cv_check_gcov to yes if tooling is present
99+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
100+AC_DEFUN([AC_TDD_GCOV],
101+[
102+ AC_ARG_ENABLE(gcov,
103+ AS_HELP_STRING([--enable-gcov],
104+ [enable coverage testing with gcov]),
105+ [use_gcov=$enableval], [use_gcov=no])
106+
107+ if test "x$use_gcov" = "xyes"; then
108+ # we need gcc:
109+ if test "$GCC" != "yes"; then
110+ AC_MSG_ERROR([GCC is required for --enable-gcov])
111+ fi
112+
113+ # Check if ccache is being used
114+ AC_CHECK_PROG(SHTOOL, shtool, shtool)
115+ case `$SHTOOL path $CC` in
116+ *ccache*[)] gcc_ccache=yes;;
117+ *[)] gcc_ccache=no;;
118+ esac
119+
120+ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
121+ AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
122+ fi
123+
124+ lcov_version_list="1.6 1.7 1.8 1.9"
125+ AC_CHECK_PROG(LCOV, lcov, lcov)
126+ AC_CHECK_PROG(GENHTML, genhtml, genhtml)
127+
128+ if test "$LCOV"; then
129+ AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
130+ glib_cv_lcov_version=invalid
131+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
132+ for lcov_check_version in $lcov_version_list; do
133+ if test "$lcov_version" = "$lcov_check_version"; then
134+ glib_cv_lcov_version="$lcov_check_version (ok)"
135+ fi
136+ done
137+ ])
138+ else
139+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
140+ AC_MSG_ERROR([$lcov_msg])
141+ fi
142+
143+ case $glib_cv_lcov_version in
144+ ""|invalid[)]
145+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
146+ AC_MSG_ERROR([$lcov_msg])
147+ LCOV="exit 0;"
148+ ;;
149+ esac
150+
151+ if test -z "$GENHTML"; then
152+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
153+ fi
154+
155+ ac_cv_check_gcov=yes
156+ ac_cv_check_lcov=yes
157+
158+ # Remove all optimization flags from CFLAGS
159+ changequote({,})
160+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
161+ changequote([,])
162+
163+ # Add the special gcc flags
164+ COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
165+ COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
166+ COVERAGE_LDFLAGS="-lgcov"
167+
168+ # Check availability of gcovr
169+ AC_CHECK_PROG(GCOVR, gcovr, gcovr)
170+ if test -z "$GCOVR"; then
171+ ac_cv_check_gcovr=no
172+ else
173+ ac_cv_check_gcovr=yes
174+ fi
175+
176+fi
177+]) # AC_TDD_GCOV
178
179=== modified file 'src/Makefile.am'
180--- src/Makefile.am 2011-09-09 08:45:39 +0000
181+++ src/Makefile.am 2012-05-30 20:36:18 +0000
182@@ -11,9 +11,13 @@
183 xutils.c \
184 xutils.h
185
186+liborg_freedesktop_evolution_indicator_la_CFLAGS = \
187+ $(COVERAGE_CFLAGS)
188+
189 liborg_freedesktop_evolution_indicator_la_LDFLAGS = \
190 -module -avoid-version \
191- $(DEPS_LIBS)
192+ $(DEPS_LIBS) \
193+ $(COVERAGE_LDFLAGS)
194
195 org-freedesktop-evolution-indicator.eplug.in : org-freedesktop-evolution-indicator.eplug.xml
196 LC_ALL=C $(INTLTOOL_MERGE) -x -u /tmp/notthere $< $@

Subscribers

People subscribed via source and target branches