[folks] tests: Port to use installed-tests
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] tests: Port to use installed-tests
- Date: Fri, 23 Jan 2015 14:07:10 +0000 (UTC)
commit bc77be3eac424004ff4571a3df6c24bdebce9714
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Jan 23 11:19:35 2015 +0000
tests: Port to use installed-tests
Port the unit tests to follow the installed-tests standard, installing
the test binaries and generated .test metadata files.
This removes the existing --enable-tests configure option, replacing it
with the standard:
• --enable-modular-tests
• --enable-installed-tests
options. --enable-modular-tests is a direct replacement for
--enable-tests, controlling whether tests are built at compile time, or
only when run under `make check`. --enable-installed-tests controls
whether tests will be installed on the system.
If the tests are installed, use
gnome-desktop-testing-runner folks
to run them all.
https://bugzilla.gnome.org/show_bug.cgi?id=743398
Makefile.am | 2 +-
NEWS | 3 +++
configure.ac | 26 +++++++++++++++++++++-----
folks/build-conf.vapi | 6 ++++++
tests/bluez/Makefile.am | 5 ++---
tests/data/Makefile.am | 5 ++++-
tests/dummy/Makefile.am | 5 ++---
tests/eds/Makefile.am | 7 +++----
tests/folks/Makefile.am | 5 ++---
tests/key-file/Makefile.am | 5 ++---
tests/lib/Makefile.am | 2 ++
tests/lib/test-utils.vala | 14 +++++++-------
tests/libsocialweb/Makefile.am | 5 ++---
tests/telepathy/Makefile.am | 9 ++++-----
tests/test.mk | 39 +++++++++++++++++++++++++++++++++++++++
tests/tracker/Makefile.am | 5 ++---
16 files changed, 102 insertions(+), 41 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4d6fa75..69a25d2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,7 @@ SUBDIRS = \
po \
$(NULL)
-if ENABLE_TESTS
+if ENABLE_BUILD_TESTS
SUBDIRS += tests
endif
diff --git a/NEWS b/NEWS
index 3b1e836..b1064b0 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Overview of changes from libfolks 0.10.1 to libfolks 0.11.0
Dependencies:
Major changes:
+ • The --enable-tests configure option has been renamed to
+ --enable-modular-tests
+ • Installed tests are now supported using --enable-installed-tests
Bugs fixed:
• Bug 641211 — Add arbitrary-field interface for applications to store trivial
diff --git a/configure.ac b/configure.ac
index 2625830..79f72dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -543,10 +543,25 @@ AM_CONDITIONAL([ENABLE_INSPECT_TOOL], [test "$with_inspect_tool" = "yes"])
# Tests
# -----------------------------------------------------------
-AC_ARG_ENABLE([tests],
- AS_HELP_STRING([--enable-tests],[Enable building of tests]),
- [enable_tests=$enableval], [enable_tests=yes])
-AM_CONDITIONAL([ENABLE_TESTS], [test x$enable_tests = xyes])
+AC_ARG_ENABLE([modular_tests],
+ AS_HELP_STRING([--disable-modular-tests],
+ [Disable build of test programs (default: no)]),,
+ [enable_modular_tests=yes])
+AC_ARG_ENABLE([installed_tests],
+ AS_HELP_STRING([--enable-installed-tests],
+ [Install test programs (default: no)]),,
+ [enable_installed_tests=no])
+
+AS_IF([test "$enable_modular_tests" = "yes" ||
+ test "$enable_installed_tests" = "yes"],
+ [enable_build_tests=yes],[enable_build_tests=no])
+AM_CONDITIONAL([ENABLE_BUILD_TESTS],
+ [test "$enable_build_tests" = "yes"])
+AC_SUBST([ENABLE_BUILD_TESTS],[$enable_build_tests])
+
+AM_CONDITIONAL([ENABLE_INSTALL_TESTS],
+ [test "$enable_installed_tests" = "yes"])
+AC_SUBST([ENABLE_INSTALL_TESTS],[$enable_installed_tests])
# -----------------------------------------------------------
# Documentation
@@ -830,5 +845,6 @@ Configure summary:
Ofono backend...............: ${enable_ofono_backend}
BlueZ backend...............: ${enable_bluez_backend}
Zeitgeist support...........: ${have_zeitgeist}
- Build tests.................: ${enable_tests}
+ Build tests.................: ${enable_modular_tests}
+ Install tests...............: ${enable_installed_tests}
"
diff --git a/folks/build-conf.vapi b/folks/build-conf.vapi
index 5458a7b..f8d157d 100644
--- a/folks/build-conf.vapi
+++ b/folks/build-conf.vapi
@@ -74,4 +74,10 @@ public class Folks.BuildConf
[CCode (cname = "PKGLIBEXECDIR")]
public static const string PKGLIBEXECDIR;
+
+ [CCode (cname = "INSTALLED_TESTS_DIR")]
+ public static const string INSTALLED_TESTS_DIR;
+
+ [CCode (cname = "INSTALLED_TESTS_META_DIR")]
+ public static const string INSTALLED_TESTS_META_DIR;
}
diff --git a/tests/bluez/Makefile.am b/tests/bluez/Makefile.am
index 46661fb..230808f 100644
--- a/tests/bluez/Makefile.am
+++ b/tests/bluez/Makefile.am
@@ -23,13 +23,12 @@ LDADD = \
$(NULL)
# in order from least to most complex
-noinst_PROGRAMS = \
+all_test_programs = \
device-properties \
individual-retrieval \
vcard-parsing \
$(NULL)
-
-TESTS = $(noinst_PROGRAMS)
+installed_tests_subdirectory = bluez
device_properties_SOURCES = \
device-properties.vala \
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 05425b4..c3385dc 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -1,5 +1,8 @@
-EXTRA_DIST = \
+include $(top_srcdir)/tests/test.mk
+
+all_test_data = \
avatar-01.jpg \
$(NULL)
+installed_tests_subdirectory = data
-include $(top_srcdir)/git.mk
diff --git a/tests/dummy/Makefile.am b/tests/dummy/Makefile.am
index 668dbe1..e6f05c3 100644
--- a/tests/dummy/Makefile.am
+++ b/tests/dummy/Makefile.am
@@ -21,13 +21,12 @@ LDADD = \
$(NULL)
# in order from least to most complex
-TESTS = \
+all_test_programs = \
individual-retrieval \
add-persona \
linkable-properties \
$(NULL)
-
-noinst_PROGRAMS = $(TESTS)
+installed_tests_subdirectory = dummy
individual_retrieval_SOURCES = \
individual-retrieval.vala \
diff --git a/tests/eds/Makefile.am b/tests/eds/Makefile.am
index ade1480..d809fbe 100644
--- a/tests/eds/Makefile.am
+++ b/tests/eds/Makefile.am
@@ -40,7 +40,7 @@ LDADD = \
$(NULL)
# in order from least to most complex
-TESTS = \
+all_test_programs = \
persona-store-tests \
individual-retrieval \
phone-details \
@@ -78,13 +78,12 @@ TESTS = \
perf \
extended-info \
$(NULL)
-
-noinst_PROGRAMS = \
- $(TESTS) \
+all_test_helper_programs = \
helper-create-many-contacts \
helper-delete-contacts \
helper-prepare-aggregator \
$(NULL)
+installed_tests_subdirectory = eds
anti_linking_SOURCES = \
anti-linking.vala \
diff --git a/tests/folks/Makefile.am b/tests/folks/Makefile.am
index 46f100b..1b3855e 100644
--- a/tests/folks/Makefile.am
+++ b/tests/folks/Makefile.am
@@ -43,7 +43,7 @@ LDADD = \
$(NULL)
# in order from least to most complex
-noinst_PROGRAMS = \
+all_test_programs = \
small-set \
abstract-field-details \
async-locking \
@@ -58,8 +58,7 @@ noinst_PROGRAMS = \
name-details \
init \
$(NULL)
-
-TESTS = $(noinst_PROGRAMS)
+installed_tests_subdirectory = folks
primary_store_changes_SOURCES = \
primary-store-changes.vala \
diff --git a/tests/key-file/Makefile.am b/tests/key-file/Makefile.am
index ef3ee67..84e57c7 100644
--- a/tests/key-file/Makefile.am
+++ b/tests/key-file/Makefile.am
@@ -22,11 +22,10 @@ LDADD = \
$(NULL)
# in order from least to most complex
-noinst_PROGRAMS = \
+all_test_programs = \
individual-retrieval \
$(NULL)
-
-TESTS = $(noinst_PROGRAMS)
+installed_tests_subdirectory = key-file
individual_retrieval_SOURCES = \
individual-retrieval.vala \
diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am
index c88c11f..988f043 100644
--- a/tests/lib/Makefile.am
+++ b/tests/lib/Makefile.am
@@ -75,6 +75,8 @@ libfolks_test_la_CPPFLAGS = \
-DABS_TOP_BUILDDIR=\"${abs_top_builddir}\" \
-DPKGLIBEXECDIR=\"${pkglibexecdir}\" \
-DPACKAGE_DATADIR=\"${pkgdatadir}\" \
+ -DINSTALLED_TESTS_DIR=\"${libexecdir}/installed-tests/${PACKAGE_TARNAME}\" \
+ -DINSTALLED_TESTS_META_DIR=\"${datadir}/installed-tests/${PACKAGE_TARNAME}\" \
$(NULL)
libfolks_test_la_LIBADD = \
diff --git a/tests/lib/test-utils.vala b/tests/lib/test-utils.vala
index b09ef16..47c4661 100644
--- a/tests/lib/test-utils.vala
+++ b/tests/lib/test-utils.vala
@@ -527,7 +527,7 @@ public class Folks.TestUtils
if (Environment.get_variable ("FOLKS_TESTS_INSTALLED") != null)
{
- execdir = BuildConf.PKGLIBEXECDIR + "/tests";
+ execdir = BuildConf.INSTALLED_TESTS_DIR + "/";
}
else
{
@@ -552,16 +552,16 @@ public class Folks.TestUtils
/**
* Return the path to a test file that is distributed in the source tarball
- * and, if installed, is installed into ${pkgdatadir}/tests.
+ * and, if installed, is installed into ${installed_tests_dir}.
*
* @param filename A filename relative to ${top_srcdir}/tests
- * or ${pkgdatadir}/tests (or equivalently, ${datadir}/folks/tests).
+ * or ${installed_tests_dir}.
*/
public static string get_source_test_data (string filename)
{
if (Environment.get_variable ("FOLKS_TESTS_INSTALLED") != null)
{
- return BuildConf.PACKAGE_DATADIR + "/tests/" + filename;
+ return BuildConf.INSTALLED_TESTS_DIR + "/" + filename;
}
else
{
@@ -571,16 +571,16 @@ public class Folks.TestUtils
/**
* Return the path to a test file that is built by "make"
- * and, if installed, is installed into ${pkgdatadir}/tests.
+ * and, if installed, is installed into ${installed_tests_dir}.
*
* @param filename A filename relative to ${top_builddir}/tests
- * or ${pkgdatadir}/tests (or equivalently, ${datadir}/folks/tests).
+ * or ${installed_tests_dir}.
*/
public static string get_built_test_data (string filename)
{
if (Environment.get_variable ("FOLKS_TESTS_INSTALLED") != null)
{
- return BuildConf.PACKAGE_DATADIR + "/tests/" + filename;
+ return BuildConf.INSTALLED_TESTS_DIR + "/" + filename;
}
else
{
diff --git a/tests/libsocialweb/Makefile.am b/tests/libsocialweb/Makefile.am
index f84c02c..3130474 100644
--- a/tests/libsocialweb/Makefile.am
+++ b/tests/libsocialweb/Makefile.am
@@ -31,12 +31,11 @@ LDADD = \
$(NULL)
# in order from least to most complex
-noinst_PROGRAMS = \
+all_test_programs = \
dummy-lsw \
aggregation \
$(NULL)
-
-TESTS = $(noinst_PROGRAMS)
+installed_tests_subdirectory = libsocialweb
dummy_lsw_SOURCES = \
dummy-lsw.vala \
diff --git a/tests/telepathy/Makefile.am b/tests/telepathy/Makefile.am
index 81be6d4..0af3ace 100644
--- a/tests/telepathy/Makefile.am
+++ b/tests/telepathy/Makefile.am
@@ -43,18 +43,17 @@ LDADD = \
-L$(top_srcdir)/backends/telepathy/lib \
$(NULL)
-TESTS = \
+all_test_programs = \
persona-store-capabilities \
individual-retrieval \
individual-properties \
init \
$(NULL)
-
-noinst_PROGRAMS = \
+all_test_helper_programs = \
fake-tp-backend \
individual-zeitgeist \
- $(TESTS) \
$(NULL)
+installed_tests_subdirectory = telepathy
fake_tp_backend_SOURCES = \
fake-tp-backend.vala \
@@ -80,7 +79,7 @@ persona_store_capabilities_SOURCES = \
persona-store-capabilities.vala \
$(NULL)
-EXTRA_DIST = \
+all_test_data = \
relationships-empty.ini \
$(NULL)
diff --git a/tests/test.mk b/tests/test.mk
index 801d17b..54f4bfa 100644
--- a/tests/test.mk
+++ b/tests/test.mk
@@ -63,3 +63,42 @@ test_ldadd = \
$(GLIB_LIBS) \
$(GEE_LIBS) \
$(NULL)
+
+# installed-tests support
+#
+# See: https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests
+#
+# The including file needs to define:
+# - all_test_programs, all_test_scripts, all_test_data,
+# all_test_helper_programs, all_test_helper_scripts
+# $(all_test_data) needs to be added to $(EXTRA_DIST) manually if needed.
+# - installed_tests_subdirectory
+
+installed_tests_subdirectory ?=
+
+installed_tests_dir = $(libexecdir)/installed-tests/$(PACKAGE_TARNAME)/$(installed_tests_subdirectory)
+installed_tests_meta_dir = $(datadir)/installed-tests/$(PACKAGE_TARNAME)/$(installed_tests_subdirectory)
+
+# Build rules
+if ENABLE_BUILD_TESTS
+TESTS = $(all_test_programs) $(all_test_scripts)
+noinst_PROGRAMS = $(all_test_programs) $(all_test_helper_programs)
+noinst_SCRIPTS = $(all_test_scripts) $(all_test_helper_scripts)
+noinst_DATA = $(all_test_data)
+endif
+
+if ENABLE_INSTALL_TESTS
+insttestdir = $(installed_tests_dir)
+insttest_PROGRAMS = $(all_test_programs) $(all_test_helper_programs)
+insttest_SCRIPTS = $(all_test_scripts) $(all_test_helper_scripts)
+insttest_DATA = $(all_test_data)
+
+testmetadir = $(installed_tests_meta_dir)
+testmeta_DATA = $(all_test_programs:=.test) $(all_test_scripts:=.test)
+endif
+
+%.test: % Makefile
+ $(AM_V_GEN) (echo "[Test]" > $ tmp; \
+ echo "Type=session" >> $ tmp; \
+ echo "Exec=env G_ENABLE_DIAGNOSTIC=0 FOLKS_TESTS_INSTALLED=1 G_MESSAGES_DEBUG=
FOLKS_TEST_EDS_LIBEXECDIR=$(libexecdir) FOLKS_TEST_TRACKER_LIBEXECDIR=$(libexecdir) $(insttestdir)/$<" >> $
tmp; \
+ mv $ tmp $@)
diff --git a/tests/tracker/Makefile.am b/tests/tracker/Makefile.am
index c8d481f..e62ccc8 100644
--- a/tests/tracker/Makefile.am
+++ b/tests/tracker/Makefile.am
@@ -37,7 +37,7 @@ LDADD = \
$(NULL)
# in order from least to most complex
-noinst_PROGRAMS = \
+all_test_programs = \
individual-retrieval \
name-details-interface \
avatar-details-interface \
@@ -97,8 +97,7 @@ noinst_PROGRAMS = \
set-duplicate-email \
set-null-avatar \
$(NULL)
-
-TESTS = $(noinst_PROGRAMS)
+installed_tests_subdirectory = tracker
individual_retrieval_SOURCES = \
individual-retrieval.vala \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]