[cheese] Add non-interactive test infrastructure
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Add non-interactive test infrastructure
- Date: Tue, 13 Dec 2011 22:16:51 +0000 (UTC)
commit 27cd08b9185dafab39b1bb7804314929d25f3396
Author: David King <amigadave amigadave com>
Date: Sun Dec 11 19:05:50 2011 +0100
Add non-interactive test infrastructure
This is just the Makefile changes, the test itself was written
separately.
.gitignore | 3 +++
Makefile.am | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
configure.ac | 11 ++++++++++-
3 files changed, 64 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 234ef44..e6b5dbd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,12 +47,15 @@ Makefile.in*
/po/cheese.pot
/po/stamp-it
/src/*.c
+/????-report.html
+/????-report.xml
/tests/cheese-test-widget
/tests/cheese-test-monitor
/tests/cheese-test-chooser
/tests/cheese-test-camera
/tests/cheese-test-flash
/tests/test-webcam-button
+/tests/test-widgets
/aclocal.m4
/Cheese-*.gir
/Cheese-*.typelib
diff --git a/Makefile.am b/Makefile.am
index 0b3eef9..4903186 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -368,6 +368,54 @@ dist_pixmaps_DATA = \
data/pixmaps/cheese-2.svg \
data/pixmaps/cheese-3.svg
+# Tests.
+check_PROGRAMS = tests/test-widgets
+tests_test_widgets_SOURCES = tests/test-widgets.c
+tests_test_widgets_CPPFLAGS = $(EXAMPLES_CPPFLAGS)
+tests_test_widgets_LDADD = \
+ $(CHEESE_LIBS) \
+ $(CHEESE_GTK_LIBS) \
+ libcheese-gtk.la
+
+if CHEESE_ENABLE_TESTS
+# test: run all tests.
+test: $(check_PROGRAMS)
+ $(AM_V_at)test -z "$(check_PROGRAMS)" || MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) $(GTESTER) --verbose $(check_PROGRAMS)
+
+# test-report: run tests and generate report.
+# perf-report: run tests with -m perf and generate report.
+# full-report: like test-report: with -m perf and -m slow.
+test-report perf-report full-report: $(check_PROGRAMS)
+ $(AM_V_at)test -z "$(check_PROGRAMS)" || { \
+ case $@ in \
+ test-report) test_options="-k";; \
+ perf-report) test_options="-k -m=perf";; \
+ full-report) test_options="-k -m=perf -m=slow";; \
+ esac ; \
+ $(GTESTER) --verbose $$test_options -o test-log.xml $(check_PROGRAMS) ; \
+ if test -d "$(top_srcdir)/.git" ; then \
+ REVISION=`git describe` ; \
+ else \
+ REVISION=$(PACKAGE_VERSION) ; \
+ fi ; \
+ echo '<?xml version="1.0"?>' > $ xml ; \
+ echo '<report-collection>' >> $ xml ; \
+ echo '<info>' >> $ xml ; \
+ echo ' <package>$(PACKAGE_NAME)</package>' >> $ xml ; \
+ echo ' <version>$(PACKAGE_VERSION)</version>' >> $ xml ; \
+ echo " <revision>$$REVISION</revision>" >> $ xml ; \
+ echo '</info>' >> $ xml ; \
+ sed '1,1s/^<?xml\b[^>?]*?>//' < test-log.xml >> $ xml ; \
+ rm test-log.xml ; \
+ echo >> $ xml ; \
+ echo '</report-collection>' >> $ xml ; \
+ $(GTESTER_REPORT) --version 2>/dev/null 1>&2 ; test "$$?" != 0 || $(GTESTER_REPORT) $ xml >$ html ; \
+ }
+else # !CHEESE_ENABLE_TESTS
+test:
+ echo "Test run disabled due to the lack of GLib testing utilities"
+endif
+
# gtk-doc
gtkdoc_builddir = $(top_builddir)/docs/reference
gtkdoc_distdir = $(top_distdir)/docs/reference
@@ -375,7 +423,8 @@ gtkdoc_srcdir = $(top_srcdir)/docs/reference
all-local: $(bin_PROGRAMS)
cd $(gtkdoc_builddir) && $(MAKE) $(AM_MAKEFLAGS) all
-check-local:
+# run make test as part of make check.
+check-local: test
cd $(gtkdoc_builddir) && $(MAKE) $(AM_MAKEFlAGS) check
clean-local:
cd $(gtkdoc_builddir) && $(MAKE) $(AM_MAKEFLAGS) clean
@@ -473,4 +522,4 @@ git-changelog-hook:
echo A git clone is required to generate a ChangeLog >&2; \
fi
-.PHONY: docs
+.PHONY: docs git-changelog-hook test test-report perf-report full-report
diff --git a/configure.ac b/configure.ac
index a3954e3..8427611 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,16 @@ AS_IF([test "x$GST_INSPECT" = "xnotfound"],
AC_MSG_WARN([$gst_runtime_plugin was not found. It needs to be installed before Cheese is run])])
done])
+# Check for GLib testing utilities.
+AC_PATH_PROG([GTESTER], [gtester], [notfound])
+AC_PATH_PROG([GTESTER_REPORT], [gtester-report], [notfound])
+AS_IF([test "x$GTESTER" = "xnotfound" -o "$GTESTER_REPORT" = "xnotfound"],
+ [AC_MSG_WARN([testing disabled as the required utilities were not found])],
+ [CHEESE_ENABLE_TESTS=true
+ AC_SUBST([GTESTER])
+ AC_SUBST([GTESTER_REPORT])])
+AM_CONDITIONAL([CHEESE_ENABLE_TESTS], [test "x$CHEESE_ENABLE_TESTS" = "xtrue"])
+
AC_MSG_CHECKING([for glib-mkenums script])
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
AS_IF([test "x$GLIB_MKENUMS" = "x"],
@@ -152,7 +162,6 @@ AS_IF([test "x$GLIB_MKENUMS" = "x"],
[AC_SUBST([GLIB_MKENUMS])
AC_MSG_RESULT([$GLIB_MKENUMS])])
-
GOBJECT_INTROSPECTION_CHECK([0.6.7])
# API documentation
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]