Merge lp:~allanlesage/libindicate/TDD into lp:libindicate/0.7

Proposed by Ted Gould
Status: Merged
Merged at revision: 445
Proposed branch: lp:~allanlesage/libindicate/TDD
Merge into: lp:libindicate/0.7
Diff against target: 250 lines (+152/-3) (has conflicts)
6 files modified
Makefile.am (+36/-0)
autogen.sh (+1/-1)
configure.ac (+18/-0)
libindicate-gtk/Makefile.am (+10/-1)
libindicate/Makefile.am (+4/-1)
m4/gcov.m4 (+83/-0)
Text conflict in configure.ac
To merge this branch: bzr merge lp:~allanlesage/libindicate/TDD
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+92403@code.launchpad.net

Description of the change

Adding a code coverage target

To post a comment you must log in.
lp:~allanlesage/libindicate/TDD updated
445. By Ted Gould

Adding in a code coverage targe

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 2011-11-21 06:53:14 +0000
3+++ Makefile.am 2012-02-10 03:13:19 +0000
4@@ -57,3 +57,39 @@
5 else \
6 echo Failed to generate AUTHORS: not a branch >&2; \
7 fi
8+
9+
10+# Coverage targets
11+
12+.PHONY: clean-gcda
13+clean-gcda:
14+ @echo Removing old coverage results
15+ -find -name '*.gcda' -print | xargs -r rm
16+
17+.PHONY: coverage-html generate-coverage-html clean-coverage-html
18+coverage-html: clean-gcda
19+ -$(MAKE) $(AM_MAKEFLAGS) -k check
20+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
21+
22+generate-coverage-html:
23+ @echo Collecting coverage data
24+ $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
25+ LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
26+
27+clean-coverage-html: clean-gcda
28+ -$(LCOV) --directory $(top_builddir) -z
29+ -rm -rf coverage.info coveragereport
30+
31+.PHONY: coverage-xml generate-coverage-xml clean-coverage-xml
32+coverage-xml: clean-gcda
33+ -$(MAKE) $(AM_MAKEFLAGS) -k check
34+ $(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml
35+
36+generate-coverage-xml:
37+ @echo Generating coverage XML report
38+ $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
39+
40+clean-coverage-xml: clean-gcda
41+ -rm -rf $(top_builddir)/coverage.xml
42+
43+clean-local: clean-coverage-html clean-coverage-xml
44
45=== modified file 'autogen.sh'
46--- autogen.sh 2009-08-18 16:28:35 +0000
47+++ autogen.sh 2012-02-10 03:13:19 +0000
48@@ -9,4 +9,4 @@
49
50 USE_GNOME2_MACROS=1 \
51 USE_COMMON_DOC_BUILD=yes \
52-gnome-autogen.sh --enable-gtk-doc
53+. gnome-autogen.sh --enable-gtk-doc
54
55=== modified file 'configure.ac'
56--- configure.ac 2011-11-21 06:53:14 +0000
57+++ configure.ac 2012-02-10 03:13:19 +0000
58@@ -112,6 +112,16 @@
59 AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3])
60
61 ###########################
62+# gcov Coverage Reporting
63+###########################
64+
65+m4_include([m4/gcov.m4])
66+AC_TDD_GCOV
67+AC_SUBST(COVERAGE_CFLAGS)
68+AC_SUBST(COVERAGE_CXXFLAGS)
69+AC_SUBST(COVERAGE_LDFLAGS)
70+
71+###########################
72 # GObject Introspection
73 ###########################
74
75@@ -357,8 +367,16 @@
76 [AC_MSG_NOTICE([ Gtk: no])],
77 [AC_MSG_NOTICE([ Gtk: yes])]
78 )
79+<<<<<<< TREE
80
81 AS_IF([test "x$enable_tests" != "xno"],
82 [AC_MSG_NOTICE([ Tests: yes])],
83 [AC_MSG_NOTICE([ Tests: no])]
84 )
85+=======
86+
87+AS_IF([test "x$use_gcov" = "xyes"],
88+ [AC_MSG_NOTICE([ gcov: yes])],
89+ [AC_MSG_NOTICE([ gcov: no])]
90+)
91+>>>>>>> MERGE-SOURCE
92
93=== modified file 'libindicate-gtk/Makefile.am'
94--- libindicate-gtk/Makefile.am 2012-01-05 20:03:32 +0000
95+++ libindicate-gtk/Makefile.am 2012-02-10 03:13:19 +0000
96@@ -35,11 +35,13 @@
97 listener.c
98
99 libindicate_gtk_la_LDFLAGS = \
100+ $(COVERAGE_LDFLAGS) \
101 -version-info $(LIBINDICATEGTK_CURRENT):$(LIBINDICATEGTK_REVISION):$(LIBINDICATEGTK_AGE) \
102 -no-undefined \
103 -export-symbols-regex "^[^_d].*"
104
105 libindicate_gtk_la_CFLAGS = \
106+ $(COVERAGE_FLAGS) \
107 -I $(top_srcdir) \
108 -Wall -Werror \
109 $(LIBINDICATEGTK_CFLAGS)
110@@ -96,7 +98,13 @@
111 GLib-2.0 \
112 GdkPixbuf-2.0 \
113 Indicate-0.6
114-IndicateGtk_0_6_gir_CFLAGS = $(LIBINDICATEGTK_CFLAGS) -I$(top_builddir) -I$(top_srcdir) -I$(top_builddir)/libindicate
115+IndicateGtk_0_6_gir_CFLAGS = \
116+ $(LIBINDICATEGTK_CFLAGS) \
117+ $(COVERAGE_CFLAGS) \
118+ -I$(top_builddir) \
119+ -I$(top_srcdir) \
120+ -I$(top_builddir)/libindicate
121+IndicateGtk_0_6_gir_LDFLAGS = $(COVERAGE_LDFLAGS)
122 IndicateGtk_0_6_gir_LIBS = libindicate-gtk$(VER).la
123 IndicateGtk_0_6_gir_SCANNERFLAGS = $(INTROSPECTION_SCANNER_ARGS)
124 IndicateGtk_0_6_gir_FILES = $(introspection_sources)
125@@ -105,6 +113,7 @@
126 # Gotta be a better way
127 IndicateGtk3_0_6_gir_INCLUDES = $(IndicateGtk_0_6_gir_INCLUDES)
128 IndicateGtk3_0_6_gir_CFLAGS = $(IndicateGtk_0_6_gir_CFLAGS)
129+IndicateGtk3_0_6_gir_LDFLAGS = $(IndicateGtk_0_6_gir_LDFLAGS)
130 IndicateGtk3_0_6_gir_LIBS = $(IndicateGtk_0_6_gir_LIBS)
131 IndicateGtk3_0_6_gir_SCANNERFLAGS = $(IndicateGtk_0_6_gir_SCANNERFLAGS)
132 IndicateGtk3_0_6_gir_FILES = $(IndicateGtk_0_6_gir_FILES)
133
134=== modified file 'libindicate/Makefile.am'
135--- libindicate/Makefile.am 2011-08-10 20:26:17 +0000
136+++ libindicate/Makefile.am 2012-02-10 03:13:19 +0000
137@@ -66,12 +66,14 @@
138 indicate-marshal.c
139
140 libindicate_la_LDFLAGS = \
141+ $(COVERAGE_LDFLAGS) \
142 -version-info $(LIBINDICATE_CURRENT):$(LIBINDICATE_REVISION):$(LIBINDICATE_AGE) \
143 -no-undefined \
144 -export-symbols-regex "^[^_d].*"
145
146 libindicate_la_CFLAGS = \
147 $(LIBINDICATE_CFLAGS) \
148+ $(COVERAGE_LDFLAGS) \
149 -Wall -Werror
150
151 libindicate_la_LIBADD = \
152@@ -135,8 +137,9 @@
153 GObject-2.0 \
154 GLib-2.0 \
155 Dbusmenu-0.4
156-Indicate_0_6_gir_CFLAGS = $(LIBINDICATE_CFLAGS) -I$(top_srcdir)
157+Indicate_0_6_gir_CFLAGS = $(LIBINDICATE_CFLAGS) $(COVERAGE_CFLAGS) -I$(top_srcdir)
158 Indicate_0_6_gir_LIBS = libindicate.la
159+Indicate_0_6_gir_LDFLAGS = $(COVERAGE_LDFLAGS)
160 Indicate_0_6_gir_FILES = $(introspection_sources)
161 Indicate_0_6_gir_NAMESPACE = Indicate
162 Indicate_0_6_gir_VERSION = 0.6
163
164=== added file 'm4/gcov.m4'
165--- m4/gcov.m4 1970-01-01 00:00:00 +0000
166+++ m4/gcov.m4 2012-02-10 03:13:19 +0000
167@@ -0,0 +1,83 @@
168+# Checks for existence of coverage tools:
169+# * gcov
170+# * lcov
171+# * genhtml
172+# * gcovr
173+#
174+# Sets ac_cv_check_gcov to yes if tooling is present
175+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
176+AC_DEFUN([AC_TDD_GCOV],
177+[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov,
178+[
179+AC_ARG_ENABLE(gcov,
180+ AS_HELP_STRING([--enable-gcov],
181+ [enable coverage testing with gcov]),
182+ [use_gcov=$enableval], [use_gcov=no])
183+
184+ if test "x$use_gcov" = "xyes"; then
185+ # we need gcc:
186+ if test "$GCC" != "yes"; then
187+ AC_MSG_ERROR([GCC is required for --enable-gcov])
188+ fi
189+
190+ # Check if ccache is being used
191+ AC_CHECK_PROG(SHTOOL, shtool, shtool)
192+ case `$SHTOOL path $CC` in
193+ *ccache*[)] gcc_ccache=yes;;
194+ *[)] gcc_ccache=no;;
195+ esac
196+
197+ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
198+ AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
199+ fi
200+
201+ lcov_version_list="1.6 1.7 1.8 1.9"
202+ AC_CHECK_PROG(LCOV, lcov, lcov)
203+ AC_CHECK_PROG(GENHTML, genhtml, genhtml)
204+ AC_CHECK_PROG(GCOVR, gcovr, gcovr)
205+
206+ if test "$LCOV"; then
207+ AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
208+ glib_cv_lcov_version=invalid
209+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
210+ for lcov_check_version in $lcov_version_list; do
211+ if test "$lcov_version" = "$lcov_check_version"; then
212+ glib_cv_lcov_version="$lcov_check_version (ok)"
213+ fi
214+ done
215+ ])
216+ else
217+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
218+ AC_MSG_ERROR([$lcov_msg])
219+ fi
220+
221+ case $glib_cv_lcov_version in
222+ ""|invalid[)]
223+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
224+ AC_MSG_ERROR([$lcov_msg])
225+ LCOV="exit 0;"
226+ ;;
227+ esac
228+
229+ if test -z "$GENHTML"; then
230+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
231+ fi
232+
233+ if test -z "$GCOVR"; then
234+ AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr])
235+ fi
236+
237+
238+ # Remove all optimization flags from CFLAGS
239+ changequote({,})
240+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
241+ changequote([,])
242+
243+ # Add the special gcc flags
244+ COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
245+ COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
246+ COVERAGE_LDFLAGS="-lgcov"
247+
248+fi
249+])]) # AC_TDD_GCOV
250+

Subscribers

People subscribed via source and target branches