← Back to team overview

ayatana-commits team mailing list archive

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

 

Allan LeSage has proposed merging lp:~allanlesage/evolution-indicator/TDD into lp:evolution-indicator.

Requested reviews:
  Charles Kerr (charlesk)

For more details, see:
https://code.launchpad.net/~allanlesage/evolution-indicator/TDD/+merge/108050

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.
-- 
https://code.launchpad.net/~allanlesage/evolution-indicator/TDD/+merge/108050
Your team ayatana-commits is subscribed to branch lp:evolution-indicator.
=== 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 @@
   else \
   	echo Failed to generate ChangeLog >&2; \
   fi
+
+include $(top_srcdir)/Makefile.am.coverage

=== 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 @@
+
+# Coverage targets
+
+.PHONY: clean-gcno clean-gcda \
+	coverage-html generate-coverage-html clean-coverage-html \
+	coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr
+
+clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr
+
+if HAVE_GCOV
+
+clean-gcno:
+	@echo Removing old coverage instrumentation
+	-find -name '*.gcno' -print | xargs -r rm
+
+clean-gcda:
+	@echo Removing old coverage results
+	-find -name '*.gcda' -print | xargs -r rm
+  
+coverage-html: clean-gcda
+	-$(MAKE) $(AM_MAKEFLAGS) -k check
+	$(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
+  
+generate-coverage-html:
+	@echo Collecting coverage data
+	$(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool
+	LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
+  
+clean-coverage-html: clean-gcda
+	-$(LCOV) --directory $(top_builddir) -z
+	-rm -rf coverage.info coveragereport
+
+if HAVE_GCOVR
+
+coverage-gcovr: clean-gcda
+	-$(MAKE) $(AM_MAKEFLAGS) -k check
+	$(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr
+	
+generate-coverage-gcovr:
+	@echo Generating coverage GCOVR report
+	$(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml
+	
+clean-coverage-gcovr: clean-gcda
+	-rm -rf $(top_builddir)/coverage.xml
+
+endif # HAVE_GCOVR
+
+endif # HAVE_GCOV

=== 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 @@
 fi
 AC_SUBST(EVO_PLUGIN_DIR)
 
+dnl ******************************
+dnl gcov coverage reporting
+dnl ******************************
+
+m4_include([m4/gcov.m4])
+AC_TDD_GCOV
+AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes])
+AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes])
+AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes])
+AC_SUBST(COVERAGE_CFLAGS)
+AC_SUBST(COVERAGE_CXXFLAGS)
+AC_SUBST(COVERAGE_LDFLAGS)
 
 dnl ******************************
 dnl i18n

=== 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 @@
+# Checks for existence of coverage tools:
+#  * gcov
+#  * lcov
+#  * genhtml
+#  * gcovr
+# 
+# Sets ac_cv_check_gcov to yes if tooling is present
+# and reports the executables to the variables LCOV, GCOVR and GENHTML.
+AC_DEFUN([AC_TDD_GCOV],
+[
+  AC_ARG_ENABLE(gcov,
+  AS_HELP_STRING([--enable-gcov],
+		 [enable coverage testing with gcov]),
+  [use_gcov=$enableval], [use_gcov=no])
+
+  if test "x$use_gcov" = "xyes"; then
+  # we need gcc:
+  if test "$GCC" != "yes"; then
+    AC_MSG_ERROR([GCC is required for --enable-gcov])
+  fi
+
+  # Check if ccache is being used
+  AC_CHECK_PROG(SHTOOL, shtool, shtool)
+  case `$SHTOOL path $CC` in
+    *ccache*[)] gcc_ccache=yes;;
+    *[)] gcc_ccache=no;;
+  esac
+
+  if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
+    AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
+  fi
+
+  lcov_version_list="1.6 1.7 1.8 1.9"
+  AC_CHECK_PROG(LCOV, lcov, lcov)
+  AC_CHECK_PROG(GENHTML, genhtml, genhtml)
+
+  if test "$LCOV"; then
+    AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [
+      glib_cv_lcov_version=invalid
+      lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
+      for lcov_check_version in $lcov_version_list; do
+        if test "$lcov_version" = "$lcov_check_version"; then
+          glib_cv_lcov_version="$lcov_check_version (ok)"
+        fi
+      done
+    ])
+  else
+    lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
+    AC_MSG_ERROR([$lcov_msg])
+  fi
+
+  case $glib_cv_lcov_version in
+    ""|invalid[)]
+      lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
+      AC_MSG_ERROR([$lcov_msg])
+      LCOV="exit 0;"
+      ;;
+  esac
+
+  if test -z "$GENHTML"; then
+    AC_MSG_ERROR([Could not find genhtml from the lcov package])
+  fi
+
+  ac_cv_check_gcov=yes
+  ac_cv_check_lcov=yes
+
+  # Remove all optimization flags from CFLAGS
+  changequote({,})
+  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
+  changequote([,])
+
+  # Add the special gcc flags
+  COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
+  COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage"	
+  COVERAGE_LDFLAGS="-lgcov"
+
+  # Check availability of gcovr
+  AC_CHECK_PROG(GCOVR, gcovr, gcovr)
+  if test -z "$GCOVR"; then
+    ac_cv_check_gcovr=no
+  else
+    ac_cv_check_gcovr=yes
+  fi
+
+fi
+]) # AC_TDD_GCOV

=== 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 @@
   xutils.c \
   xutils.h
 
+liborg_freedesktop_evolution_indicator_la_CFLAGS = \
+	$(COVERAGE_CFLAGS)
+
 liborg_freedesktop_evolution_indicator_la_LDFLAGS = \
 	-module -avoid-version	\
-	$(DEPS_LIBS)
+	$(DEPS_LIBS) \
+	$(COVERAGE_LDFLAGS)
 
 org-freedesktop-evolution-indicator.eplug.in : org-freedesktop-evolution-indicator.eplug.xml
 	LC_ALL=C $(INTLTOOL_MERGE) -x -u /tmp/notthere $< $@