build: Add lcov make targets from telepathy-glib
authorPhilip Withnall <philip@tecnocode.co.uk>
Sun, 8 Jan 2012 23:16:14 +0000 (23:16 +0000)
committerPhilip Withnall <philip@tecnocode.co.uk>
Sun, 8 Jan 2012 23:35:07 +0000 (23:35 +0000)
Add lcov.mk, copied from telepathy-glib:
http://cgit.freedesktop.org/telepathy/telepathy-glib/tree/tools/lcov.am
with the tp-glib–specific bits removed.

These targets are only useful if folks is compiled with
--enable-code-coverage.

To run the test suite and generate a report, run `make lcov-check`. To just
generate a report without running the test suite, run `make lcov-report`.

The .info file and generated report are only deleted by
`make maintainer-clean`, since the developer might want to refer to them
across other cleans.

Closes: https://bugzilla.gnome.org/show_bug.cgi?id=659610

Makefile.am
lcov.mk [new file with mode: 0644]

index 783af12..ba7ee91 100644 (file)
@@ -20,11 +20,13 @@ DISTCHECK_CONFIGURE_FLAGS = \
 EXTRA_DIST = \
        autogen.sh \
        check.mk \
+       lcov.mk \
        valgrind.mk \
        $(NULL)
 
 MAINTAINERCLEANFILES = \
        ABOUT-NLS \
+       $(top_builddir)/lcov.info \
        $(srcdir)/INSTALL \
        $(srcdir)/aclocal.m4 \
        $(srcdir)/compile \
@@ -51,6 +53,16 @@ MAINTAINERCLEANFILES = \
        po/remove-potcdate.sin \
        $(NULL)
 
+maintainer-clean-local: maintainer-clean-local-lcov
+maintainer-clean-local-lcov:
+       rm -rf $(top_builddir)/lcov.html
+
+.PHONY: maintainer-clean-local-lcov
+
+GITIGNOREFILES = \
+       $(top_builddir)/lcov.html/* \
+       $(NULL)
+
 distclean-local:
        if test "x$(srcdir)" = "x."; then :; else \
                rm -f ChangeLog; \
@@ -79,4 +91,7 @@ ChangeLog:
 
 .PHONY: ChangeLog
 
+# Code coverage support
+include lcov.mk
+
 -include $(top_srcdir)/git.mk
diff --git a/lcov.mk b/lcov.mk
new file mode 100644 (file)
index 0000000..2ea2531
--- /dev/null
+++ b/lcov.mk
@@ -0,0 +1,23 @@
+# From http://cgit.freedesktop.org/telepathy/telepathy-glib/tree/tools/lcov.am
+
+lcov-reset:
+       lcov --directory @top_srcdir@ --zerocounters
+
+lcov-report:
+       lcov --directory @top_srcdir@ --capture \
+               --output-file @top_builddir@/lcov.info
+       $(mkdir_p) @top_builddir@/lcov.html
+       git_commit=`GIT_DIR=@top_srcdir@/.git git log -1 --pretty=format:%h 2>/dev/null`;\
+       genhtml --title "@PACKAGE_STRING@ $$git_commit" \
+               --output-directory @top_builddir@/lcov.html lcov.info
+       @echo
+       @echo 'lcov report can be found in:'
+       @echo 'file://@abs_top_builddir@/lcov.html/index.html'
+       @echo
+
+lcov-check:
+       $(MAKE) lcov-reset
+       $(MAKE) check $(LCOV_CHECK_ARGS)
+       $(MAKE) lcov-report
+
+## vim:set ft=automake: