Merge lp:~jpakkane/unity-lens-video/coverage into lp:~stolowski/unity-lens-video/vala-rewrite

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 157
Merged at revision: 156
Proposed branch: lp:~jpakkane/unity-lens-video/coverage
Merge into: lp:~stolowski/unity-lens-video/vala-rewrite
Diff against target: 269 lines (+171/-7)
7 files modified
Makefile.am (+2/-0)
Makefile.am.coverage (+48/-0)
configure.ac (+16/-0)
m4/gcov.m4 (+86/-0)
src/Makefile.am (+3/-0)
tests/unit/Makefile.am (+15/-7)
tests/unit/config-tests.vala.in (+1/-0)
To merge this branch: bzr merge lp:~jpakkane/unity-lens-video/coverage
Reviewer Review Type Date Requested Status
Paweł Stołowski Approve
Review via email: mp+148700@code.launchpad.net

Commit message

Coverage support.

Description of the change

Coverage support.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Please also update sources in tests/unit/Makefile.am to include all vala files from src/ (except for config.vala, main.vala and mocked class(es)). That way coverage report will be more accurate.

Apart from that it works fine.

review: Needs Fixing
156. By Jussi Pakkanen

Merged changes.

157. By Jussi Pakkanen

Added vala sources to list so they show up in coverage measurements.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

LGTM. +1

review: Approve

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 2012-11-22 12:23:14 +0000
3+++ Makefile.am 2013-02-19 12:24:23 +0000
4@@ -1,3 +1,5 @@
5 SUBDIRS = src po tests/unit vapi data
6
7 DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall
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 2013-02-19 12:24:23 +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 2013-02-18 11:14:01 +0000
66+++ configure.ac 2013-02-19 12:24:23 +0000
67@@ -51,6 +51,17 @@
68 INTLTOOL_LENS_RULE='%.lens: %.lens.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
69 AC_SUBST(INTLTOOL_LENS_RULE)
70
71+###########################
72+# gcov coverage reporting
73+###########################
74+m4_include([m4/gcov.m4])
75+AC_TDD_GCOV
76+AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
77+AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
78+AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
79+AC_SUBST(COVERAGE_CFLAGS)
80+AC_SUBST(COVERAGE_LDFLAGS)
81+
82 #####################################################
83 # Check for module and library dependancies
84 #####################################################
85@@ -189,4 +200,9 @@
86 Extra ValaFlags : ${CPPFLAGS} $MAINTAINER_VALAFLAGS
87
88 Lenses Directory: ${LENSESDIR}
89+
90+ Testing
91+ Headless tests : ${enable_headless_tests}
92+ Coverage reporting : ${use_gcov}
93+
94 ])
95
96=== added directory 'm4'
97=== added file 'm4/gcov.m4'
98--- m4/gcov.m4 1970-01-01 00:00:00 +0000
99+++ m4/gcov.m4 2013-02-19 12:24:23 +0000
100@@ -0,0 +1,86 @@
101+# Checks for existence of coverage tools:
102+# * gcov
103+# * lcov
104+# * genhtml
105+# * gcovr
106+#
107+# Sets ac_cv_check_gcov to yes if tooling is present
108+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
109+AC_DEFUN([AC_TDD_GCOV],
110+[
111+ AC_ARG_ENABLE(gcov,
112+ AS_HELP_STRING([--enable-gcov],
113+ [enable coverage testing with gcov]),
114+ [use_gcov=$enableval], [use_gcov=no])
115+
116+ if test "x$use_gcov" = "xyes"; then
117+ # we need gcc:
118+ if test "$GCC" != "yes"; then
119+ AC_MSG_ERROR([GCC is required for --enable-gcov])
120+ fi
121+
122+ # Check if ccache is being used
123+ AC_CHECK_PROG(SHTOOL, shtool, shtool)
124+ case `$SHTOOL path $CC` in
125+ *ccache*[)] gcc_ccache=yes;;
126+ *[)] gcc_ccache=no;;
127+ esac
128+
129+ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
130+ AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
131+ fi
132+
133+ lcov_version_list="1.6 1.7 1.8 1.9"
134+ AC_CHECK_PROG(LCOV, lcov, lcov)
135+ AC_CHECK_PROG(GENHTML, genhtml, genhtml)
136+
137+ if test "$LCOV"; then
138+ AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
139+ glib_cv_lcov_version=invalid
140+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
141+ for lcov_check_version in $lcov_version_list; do
142+ if test "$lcov_version" = "$lcov_check_version"; then
143+ glib_cv_lcov_version="$lcov_check_version (ok)"
144+ fi
145+ done
146+ ])
147+ else
148+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
149+ AC_MSG_ERROR([$lcov_msg])
150+ fi
151+
152+ case $glib_cv_lcov_version in
153+ ""|invalid[)]
154+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
155+ AC_MSG_ERROR([$lcov_msg])
156+ LCOV="exit 0;"
157+ ;;
158+ esac
159+
160+ if test -z "$GENHTML"; then
161+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
162+ fi
163+
164+ ac_cv_check_gcov=yes
165+ ac_cv_check_lcov=yes
166+
167+ # Remove all optimization flags from CFLAGS
168+ changequote({,})
169+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
170+ changequote([,])
171+
172+ # Add the special gcc flags
173+ COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
174+ COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"
175+ COVERAGE_LDFLAGS="-lgcov"
176+
177+ # Check availability of gcovr
178+ AC_CHECK_PROG(GCOVR, gcovr, gcovr)
179+ if test -z "$GCOVR"; then
180+ ac_cv_check_gcovr=no
181+ else
182+ ac_cv_check_gcovr=yes
183+ fi
184+
185+fi
186+]) # AC_TDD_GCOV
187
188=== modified file 'src/Makefile.am'
189--- src/Makefile.am 2013-02-18 11:14:01 +0000
190+++ src/Makefile.am 2013-02-19 12:24:23 +0000
191@@ -5,6 +5,9 @@
192
193 DATADIR = $(datadir)
194
195+AM_CPPFLAGS = $(COVERAGE_CFLAGS)
196+AM_LDFLAGS = $(COVERAGE_LDFLAGS)
197+
198 pkglibexec_PROGRAMS = \
199 unity-video-lens-daemon \
200 unity-scope-video-remote \
201
202=== modified file 'tests/unit/Makefile.am'
203--- tests/unit/Makefile.am 2012-11-27 12:17:56 +0000
204+++ tests/unit/Makefile.am 2013-02-19 12:24:23 +0000
205@@ -17,6 +17,8 @@
206 --pkg json-glib-1.0 \
207 --pkg glib-2.0 \
208 --pkg zeitgeist-1.0 \
209+ --pkg libsoup-gnome-2.4 \
210+ --pkg libsoup-2.4 \
211 --vapidir $(srcdir) \
212 --vapidir $(top_srcdir)/vapi \
213 --target-glib=2.26 \
214@@ -31,8 +33,11 @@
215 -I$(srcdir) \
216 -I$(top_srcdir)/src \
217 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
218+ $(COVERAGE_CFLAGS) \
219 $(NULL)
220
221+AM_LDFLAGS = $(COVERAGE_LDFLAGS)
222+
223 if !ENABLE_C_WARNINGS
224 AM_CPPFLAGS += -w
225 endif
226@@ -41,23 +46,26 @@
227 test-locate.vala \
228 thumbnailer-mock.vala \
229 config-tests.vala \
230- ../../src/locate.vala \
231- ../../src/utils.vala \
232- ../../src/video-file.vala \
233+ $(top_srcdir)/src/locate.vala \
234+ $(top_srcdir)/src/utils.vala \
235+ $(top_srcdir)/src/video-file.vala \
236 $(NULL)
237
238 test_utils_VALASOURCES = \
239 test-utils.vala \
240 config-tests.vala \
241- ../../src/utils.vala \
242+ $(top_srcdir)/src/utils.vala \
243 $(NULL)
244
245 test_ubuntu_video_search_VALASOURCES = \
246 test-ubuntu-video-search.vala \
247 config-tests.vala \
248- ../../src/remote-scope-globals.vala \
249- ../../src/ubuntu-video-search.vala \
250- ../../src/video-file.vala \
251+ $(top_srcdir)/src/remote-scope-globals.vala \
252+ $(top_srcdir)/src/ubuntu-video-search.vala \
253+ $(top_srcdir)/src/video-file.vala \
254+ $(top_srcdir)/src/remote-scope.vala \
255+ $(top_srcdir)/src/remote-uri.vala \
256+ $(top_srcdir)/src/utils.vala \
257 $(NULL)
258
259 nodist_test_locate_SOURCES = $(test_locate_VALASOURCES:.vala=.c)
260
261=== modified file 'tests/unit/config-tests.vala.in'
262--- tests/unit/config-tests.vala.in 2012-11-27 12:17:56 +0000
263+++ tests/unit/config-tests.vala.in 2013-02-19 12:24:23 +0000
264@@ -2,4 +2,5 @@
265 const string TESTDATADIR = "@abs_top_srcdir@/tests/unit/data";
266 const string LOCALEDIR = "@DATADIR@/locale";
267 const string PACKAGE = "@PACKAGE@";
268+ const string VERSION = "@VERSION@";
269 }

Subscribers

People subscribed via source and target branches