[gnome-weather] Add coverage reports for tests
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] Add coverage reports for tests
- Date: Mon, 3 Feb 2014 19:54:53 +0000 (UTC)
commit f8fca13f50480707eac52236fc3d89c6340ba20e
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Feb 3 20:04:28 2014 +0100
Add coverage reports for tests
Using the new lcov support in gjs, we can see how complete our
test suite is, which nice colored HTML reports.
configure.ac | 24 ++++++++++++++++++++++++
tests/Makefile.am | 17 +++++++++++++++++
tests/testutil.py | 2 +-
3 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6583e35..594c686 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,30 @@ AC_ARG_ENABLE(dogtail,
[test using dogtail [default=yes]])],,
enable_dogtail=yes)
AM_CONDITIONAL(ENABLE_DOGTAIL, test "$enable_dogtail" != no)
+# coverage
+AC_ARG_ENABLE([coverage],
+ [AS_HELP_STRING([--enable-coverage],
+ [enable code coverage])],
+ , [enable_coverage=no])
+if test x$enable_coverage = xyes; then
+ if test x$GCC != xyes; then
+ AC_MSG_ERROR([GCC is required for --enable-coverage])
+ fi
+
+ AC_PATH_TOOL([LCOV], [lcov])
+ AC_PATH_TOOL([GENHTML], [genhtml])
+
+ if test x$LCOV = x || test x$GENHTML = x; then
+ AC_MSG_ERROR([lcov and genhtml are required for --enable-coverage])
+ fi
+
+ # only enable these if we ever want code coverage for libgd
+ # (which we don't)
+ #CFLAGS="$CFLAGS -g -O0 --coverage"
+ #CXXFLAGS="$CXXFLAGS -g -O0 --coverage"
+ #LIBS="$LIBS -lgcov"
+fi
+AM_CONDITIONAL([ENABLE_COVERAGE], [test x$enable_coverage = xyes])
GLIB_TESTS
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0ce8ad4..6a959a2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,23 @@ dogtail_tests = \
if ENABLE_DOGTAIL
dist_test_scripts = $(dogtail_tests)
dist_test_data = testutil.py
+
+CLEANFILES += *.pyc
+
+if ENABLE_COVERAGE
+lcov:
+ ( cd $(abs_top_builddir) ; $(TEST_ENVIRONMENT) $(GJS) --coverage-output=$(abs_builddir) \
+ $(foreach source,$(wildcard $(abs_top_srcdir)/src/*.js),-C $(abs_top_srcdir)/src/$(notdir $(source)))
\
+ $(abs_top_builddir)/src/org.gnome.Weather.Application ) & sleep 2 && $(MAKE) $(AM_MAKEFLAGS) check
+ $(GENHTML) $(builddir)/coverage.lcov
+
+clean-local:
+ rm -rf $(builddir)/src
+
+CLEANFILES += *.html *.png *.css coverage.lcov
+GITIGNOREFILES = src/
+endif
+
else
EXTRA_DIST += testutil.py $(dogtail_tests)
endif
diff --git a/tests/testutil.py b/tests/testutil.py
index de90d49..8c3d60f 100644
--- a/tests/testutil.py
+++ b/tests/testutil.py
@@ -39,7 +39,7 @@ def _do_bus_call(method, params):
def start():
_do_bus_call("Activate", GLib.Variant('(a{sv})', ([],)))
- utils.doDelay(2)
+ utils.doDelay(3)
app = tree.root.application(APPLICATION_ID)
focus.application(APPLICATION_ID)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]