[geocode-glib] build: Add installed-tests support
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] build: Add installed-tests support
- Date: Tue, 17 Jan 2017 10:42:22 +0000 (UTC)
commit f1650bec04d5dcb267c549d4b7c243e89baa0822
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Oct 14 12:16:40 2016 +0100
build: Add installed-tests support
This means the tests are installed on the system, and can be run using
gnome-desktop-testing-runner geocode-glib-1.0
This means they will be run as integration tests on systems like
gnome-continuous, which may help to catch bugs caused by integration
changes with other modules.
The tests themselves have not actually changed.
https://bugzilla.gnome.org/show_bug.cgi?id=772928
Makefile.am | 7 ++-
configure.ac | 20 ++++++
geocode-glib/tests/Makefile.am | 25 ++++----
glib-tap.mk | 135 ++++++++++++++++++++++++++++++++++++++++
tap-test | 5 ++
5 files changed, 179 insertions(+), 13 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c30ba1d..b1cf087 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,11 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = geocode-glib po docs icons
-EXTRA_DIST = gtk-doc.make
+EXTRA_DIST = \
+ glib-tap.mk \
+ gtk-doc.make \
+ tap-test \
+ $(NULL)
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc=yes --enable-introspection=yes
@@ -13,6 +17,7 @@ MAINTAINERCLEANFILES = \
$(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN) \
$(GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL) \
build-aux/ \
+ build-aux/tap-driver.sh \
INSTALL \
omf.make \
gtk-doc.make \
diff --git a/configure.ac b/configure.ac
index cc0940a..fcc0e68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,8 @@ AX_IS_RELEASE([git-directory])
AC_CONFIG_SRCDIR([geocode-glib/geocode-glib.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_REQUIRE_AUX_FILE([tap-driver.sh])
AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip check-news subdir-objects])
AX_CHECK_ENABLE_DEBUG([yes])
@@ -76,6 +78,24 @@ AX_COMPILER_FLAGS([WARN_CFLAGS],[WARN_LDFLAGS])
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
AC_SUBST(GLIB_MKENUMS)
+# installed-tests
+AC_ARG_ENABLE([always_build_tests],
+ AS_HELP_STRING([--enable-always-build-tests],
+ [Enable always building tests (default: yes)]),,
+ [enable_always_build_tests=yes])
+AC_ARG_ENABLE([installed_tests],
+ AS_HELP_STRING([--enable-installed-tests],
+ [Install test programs (default: no)]),,
+ [enable_installed_tests=no])
+
+AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS],
+ [test "$enable_always_build_tests" = "yes"])
+AC_SUBST([ENABLE_ALWAYS_BUILD_TESTS],[$enable_always_build_tests])
+
+AM_CONDITIONAL([ENABLE_INSTALLED_TESTS],
+ [test "$enable_installed_tests" = "yes"])
+AC_SUBST([ENABLE_INSTALLED_TESTS],[$enable_installed_tests])
+
AC_CONFIG_FILES([
Makefile
geocode-glib-1.0.pc
diff --git a/geocode-glib/tests/Makefile.am b/geocode-glib/tests/Makefile.am
index 03d62fc..b3a0fb3 100644
--- a/geocode-glib/tests/Makefile.am
+++ b/geocode-glib/tests/Makefile.am
@@ -1,12 +1,7 @@
-TESTS = geo-uri geocode-glib
-noinst_PROGRAMS = $(TESTS)
+include $(top_srcdir)/glib-tap.mk
-TESTS_ENVIRONMENT = \
- G_TEST_SRCDIR="$(abs_srcdir)" \
- G_TEST_BUILDDIR="$(abs_builddir)" \
- G_DEBUG=gc-friendly \
- MALLOC_CHECK_=2 \
- MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
+installed_testdir = $(libexecdir)/installed-tests/geocode-glib-@GCLIB_API_VERSION@
+installed_test_metadir = $(datadir)/installed-tests/geocode-glib-@GCLIB_API_VERSION@
AM_CPPFLAGS = \
-I$(top_srcdir) \
@@ -22,15 +17,21 @@ AM_LDFLAGS = \
$(WARN_LDFLAGS) \
$(NULL)
+test_programs = \
+ geo-uri \
+ geocode-glib \
+ $(NULL)
+
+geo_uri_LDADD = $(top_builddir)/geocode-glib/libgeocode-glib.la $(GEOCODE_LIBS)
+geocode_glib_LDADD = $(top_builddir)/geocode-glib/libgeocode-glib.la $(GEOCODE_LIBS)
+
+geo_uri_SOURCES = geo-uri.c
geocode_glib_SOURCES = \
geocode-nominatim-test.h \
geocode-nominatim-test.c \
geocode-glib.c
-geo_uri_LDADD = $(top_builddir)/geocode-glib/libgeocode-glib.la $(GEOCODE_LIBS)
-geocode_glib_LDADD = $(top_builddir)/geocode-glib/libgeocode-glib.la $(GEOCODE_LIBS)
-
-EXTRA_DIST = \
+dist_test_data = \
locale_format.json \
locale_name.json \
nominatim-area.json \
diff --git a/glib-tap.mk b/glib-tap.mk
new file mode 100644
index 0000000..2456c7d
--- /dev/null
+++ b/glib-tap.mk
@@ -0,0 +1,135 @@
+# GLIB - Library of useful C routines
+
+TESTS_ENVIRONMENT= \
+ G_TEST_SRCDIR="$(abs_srcdir)" \
+ G_TEST_BUILDDIR="$(abs_builddir)" \
+ G_DEBUG=gc-friendly \
+ MALLOC_CHECK_=2 \
+ MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
+LOG_COMPILER = $(top_srcdir)/tap-test
+
+NULL =
+
+# initialize variables for unconditional += appending
+BUILT_SOURCES =
+BUILT_EXTRA_DIST =
+CLEANFILES = *.log *.trs
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+EXTRA_DIST =
+TESTS =
+
+installed_test_LTLIBRARIES =
+installed_test_PROGRAMS =
+installed_test_SCRIPTS =
+nobase_installed_test_DATA =
+
+noinst_LTLIBRARIES =
+noinst_PROGRAMS =
+noinst_SCRIPTS =
+noinst_DATA =
+
+check_LTLIBRARIES =
+check_PROGRAMS =
+check_SCRIPTS =
+check_DATA =
+
+# We support a fairly large range of possible variables. It is expected that all types of files in a test
suite
+# will belong in exactly one of the following variables.
+#
+# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
+#
+# test_programs, test_scripts, test_data, test_ltlibraries
+#
+# The above are used to list files that are involved in both uninstalled and installed testing. The
+# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
+# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data
is
+# installed in the same way as it appears in the package layout.
+#
+# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
+# like so:
+#
+# installed_test_programs, uninstalled_test_programs
+# installed_test_scripts, uninstalled_test_scripts
+# installed_test_data, uninstalled_test_data
+# installed_test_ltlibraries, uninstalled_test_ltlibraries
+#
+# Additionally, we support 'extra' infixes for programs and scripts. This is used for support
programs/scripts
+# that should not themselves be run as testcases (but exist to be used from other testcases):
+#
+# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
+# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
+#
+# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or
data
+# file automatically end up in the tarball.
+#
+# dist_test_scripts, dist_test_data, dist_test_extra_scripts
+# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
+# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
+#
+# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows
the
+# standard automake convention of not disting programs scripts or data by default.
+#
+# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their
disted
+# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
+# gtester. That's a bit strange for scripts, but it's possible.
+
+TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
+ $(dist_test_scripts) $(dist_uninstalled_test_scripts)
+
+# Note: build even the installed-only targets during 'make check' to ensure that they still work.
+# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
+# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
+# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
+all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
+ $(test_extra_programs) $(uninstalled_test_extra_programs)
$(installed_test_extra_programs)
+all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
+ $(test_extra_scripts) $(uninstalled_test_extra_scripts)
$(installed_test_extra_scripts)
+all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts)
\
+ $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts)
$(dist_installed_test_extra_scripts)
+all_test_scripts += $(all_dist_test_scripts)
+EXTRA_DIST += $(all_dist_test_scripts)
+all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data)
+all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
+all_test_data += $(all_dist_test_data)
+EXTRA_DIST += $(all_dist_test_data)
+all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
+
+if ENABLE_ALWAYS_BUILD_TESTS
+noinst_LTLIBRARIES += $(all_test_ltlibs)
+noinst_PROGRAMS += $(all_test_programs)
+noinst_SCRIPTS += $(all_test_scripts)
+noinst_DATA += $(all_test_data)
+else
+check_LTLIBRARIES += $(all_test_ltlibs)
+check_PROGRAMS += $(all_test_programs)
+check_SCRIPTS += $(all_test_scripts)
+check_DATA += $(all_test_data)
+endif
+
+if ENABLE_INSTALLED_TESTS
+installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
+ $(test_extra_programs) $(installed_test_extra_programs)
+installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
+ $(test_extra_scripts) $(installed_test_extra_scripts)
+installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
+ $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
+nobase_installed_test_DATA += $(test_data) $(installed_test_data)
+nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
+installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
+installed_testcases = $(test_programs) $(installed_test_programs) \
+ $(test_scripts) $(installed_test_scripts) \
+ $(dist_test_scripts) $(dist_installed_test_scripts)
+
+installed_test_meta_DATA = $(installed_testcases:=.test)
+
+%.test: %$(EXEEXT) Makefile
+ $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
+ echo 'Type=session' >> $@.tmp; \
+ echo 'Exec=$(installed_testdir)/$(notdir $<) --tap' >> $@.tmp; \
+ echo 'Output=TAP' >> $@.tmp; \
+ mv $@.tmp $@)
+
+CLEANFILES += $(installed_test_meta_DATA)
+endif
diff --git a/tap-test b/tap-test
new file mode 100755
index 0000000..481e333
--- /dev/null
+++ b/tap-test
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+# run a GTest in tap mode. The test binary is passed as $1
+
+$1 -k --tap
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]