[glib/wip/test-cleanup: 4/4] Rework the build system for a new tests approach



commit 491ee49d44e3311e18bebe4deb72747294540f40
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu May 30 00:07:32 2013 -0400

    Rework the build system for a new tests approach
    
    Perform a substantial cleanup of the build system with respect to
    building and installing testcases.
    
    By default, tests are no longer compiled as part of 'make'.  They will
    be built when 'make check' is run.  The old behaviour can be obtained
    with --enable-always-build-tests.
    
    --disable-modular-tests is gone (because tests are no longer built by
    default).  There is no longer any way to cause 'make check' to be a
    no-op, but that's not very useful anyway.
    
    A new glibtests.m4 file is introduced.  Along with a substantially
    expanded Makefile.decl, this provides for consistent handling of
    --enable-installed-tests and --enable-always-build-tests (mentioned
    above).
    
    Port our various test-installing Makefiles to the new framework.  This
    is a net reduction of about ~350 lines of Makefile and configure.ac.
    
    This patch substantially improves the situation in the toplevel tests/
    directory.  Things are now somewhat under control there.  There were
    some tests being built that weren't even being run and we run those now.
    The long-running GObject performance tests in this directory have been
    removed from 'make check' because they take too long.
    
    There is one regression in this patch: the appinfo tests can no longer
    be installed due to an inability to handle differently-generated data
    files for installed vs. uninstalled tests.  I could probably work around
    this, but I lack the will to do so now and I think we may be able to fix
    this in GLib itself by introducing proper support for relative pathnames
    to desktop files.

 Makefile.am                                        |    7 +-
 Makefile.decl                                      |   90 ++++
 configure.ac                                       |   12 +-
 gio/Makefile.am                                    |    6 +-
 gio/tests/Makefile.am                              |  484 +++++++-------------
 gio/tests/gdbus-object-manager-example/Makefile.am |   28 +-
 glib/Makefile.am                                   |    5 +-
 glib/tests/Makefile.am                             |  142 ++-----
 gobject/Makefile.am                                |    5 +-
 gobject/tests/Makefile.am                          |   30 +-
 m4macros/glibtests.m4                              |   28 ++
 tests/Makefile.am                                  |  273 +++++-------
 tests/gobject/Makefile.am                          |  118 ++---
 tests/refcount/Makefile.am                         |   32 +-
 14 files changed, 492 insertions(+), 768 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index b2555ad..b487001 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,13 +6,8 @@ include $(top_srcdir)/Makefile.decl
 
 ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
 
-SUBDIRS = . m4macros glib gmodule gthread gobject gio po docs
+SUBDIRS = . m4macros glib gmodule gthread gobject gio po docs tests
 DIST_SUBDIRS = $(SUBDIRS) build
-if BUILD_MODULAR_TESTS
-SUBDIRS += tests 
-else
-DIST_SUBDIRS += tests
-endif
 
 bin_SCRIPTS = glib-gettextize
 
diff --git a/Makefile.decl b/Makefile.decl
index 067e7e5..1a01183 100644
--- a/Makefile.decl
+++ b/Makefile.decl
@@ -8,6 +8,18 @@ GTESTER_REPORT = $(top_builddir)/glib/gtester-report   # for the GLIB package
 EXTRA_DIST =
 TEST_PROGS =
 
+installed_test_PROGRAMS =
+installed_test_SCRIPTS =
+nobase_installed_test_DATA =
+installed_test_DATA =
+nobase_dist_installed_test_DATA =
+dist_installed_test_DATA =
+
+noinst_PROGRAMS =
+noinst_SCRIPTS =
+check_PROGRAMS =
+check_SCRIPTS =
+
 ### testing rules
 
 # test: run all tests in cwd and subdirs
@@ -95,3 +107,81 @@ lcov-clean:
 
 # run tests in cwd as part of make check
 check-local: test-nonrecursive
+
+# 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
+#
+# 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
+#
+# 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.
+
+# we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
+TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) 
$(uninstalled_test_scripts) \
+                      $(dist_test_scripts) $(dist_uninstalled_test_scripts))
+EXTRA_DIST += $(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)
+
+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) $(test_installed_extra_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) \
+                              $(dist_test_data) $(dist_installed_test_data)
+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)/$<' >> $  tmp; \
+       mv $  tmp $@)
+endif
+
+if ENABLE_ALWAYS_BUILD_TESTS
+noinst_PROGRAMS += $(test_programs) $(uninstalled_test_programs) \
+                   $(test_extra_programs) $(uninstalled_test_extra_programs)
+noinst_SCRIPTS += $(test_scripts) $(uninstalled_test_scripts) \
+                  $(test_extra_scripts) $(uninstalled_test_extra_scripts) \
+                  $(dist_test_scripts) $(dist_test_extra_scripts) \
+                  $(dist_uninstalled_test_scripts) $(dist_uninstalled_test_scripts)
+else
+check_PROGRAMS += $(test_programs) $(uninstalled_test_programs) \
+                  $(test_extra_programs) $(uninstalled_test_extra_programs)
+check_SCRIPTS += $(test_scripts) $(uninstalled_test_scripts) \
+                 $(test_extra_scripts) $(uninstalled_test_extra_scripts) \
+                 $(dist_test_scripts) $(dist_test_extra_scripts) \
+                 $(dist_uninstalled_test_scripts) $(dist_uninstalled_test_scripts)
+endif
diff --git a/configure.ac b/configure.ac
index 47a7d16..da999ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -254,16 +254,8 @@ AC_ARG_ENABLE(rebuilds,
               [AS_HELP_STRING([--disable-rebuilds],
                               [disable all source autogeneration rules])],,
               [enable_rebuilds=yes])
-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])
-AM_CONDITIONAL(BUILD_MODULAR_TESTS, test x$enable_modular_tests = xyes || test x$enable_installed_tests=xyes)
-AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
+
+GLIB_TESTS
 
 AC_MSG_CHECKING([whether to enable garbage collector friendliness])
 AS_IF([test "x$enable_gc_friendly" = "xyes"], [
diff --git a/gio/Makefile.am b/gio/Makefile.am
index ff66263..75b0484 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -233,7 +233,7 @@ platform_libadd += win32/libgiowin32.la
 platform_deps += win32/libgiowin32.la
 endif
 
-SUBDIRS += .
+SUBDIRS += . tests
 
 if HAVE_FAM
 SUBDIRS += fam
@@ -327,10 +327,6 @@ giowin32include_HEADERS = \
 
 endif
 
-if BUILD_MODULAR_TESTS
-SUBDIRS += tests 
-endif
-
 libgio_2_0_la_SOURCES =                \
        gappinfo.c              \
        gasynchelper.c          \
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index 948be46..cabe732 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -1,220 +1,200 @@
-
-NULL =
-BUILT_SOURCES =
-
 include $(top_srcdir)/Makefile.decl
-
-insttestdir = $(pkglibexecdir)/installed-tests
+BUILT_SOURCES =
+NULL =
 
 SUBDIRS = gdbus-object-manager-example services
 
-AM_CPPFLAGS =                          \
-       -DG_LOG_DOMAIN=\"GLib-GIO\"     \
-       $(gio_INCLUDES)                 \
-       $(GLIB_DEBUG_FLAGS)             \
-       -I$(top_builddir)/gio           \
-       -I$(top_srcdir)/gio             \
-       $(DBUS1_CFLAGS)                 \
-       -DSRCDIR=\""$(srcdir)"\"        \
-       -DBUILDDIR=\""$(abs_builddir)"\"        \
-       -DTEST_SERVICES=\""$(abs_top_builddir)/gio/tests/services"\"
-
-AM_CFLAGS = $(GLIB_WARN_CFLAGS)
-
-noinst_PROGRAMS = $(TEST_PROGS) $(SAMPLE_PROGS)
-noinst_DATA = $(MISC_STUFF)
-
-LDADD     =                                    \
-       $(top_builddir)/glib/libglib-2.0.la             \
-       $(top_builddir)/gthread/libgthread-2.0.la       \
+LDADD = \
+       $(top_builddir)/glib/libglib-2.0.la             \
        $(top_builddir)/gobject/libgobject-2.0.la       \
        $(top_builddir)/gmodule/libgmodule-2.0.la       \
        $(top_builddir)/gio/libgio-2.0.la
+AM_CPPFLAGS = $(gio_INCLUDES) $(GLIB_DEBUG_FLAGS) -I$(top_builddir)/gio -I$(top_srcdir)/gio
+DEFS = -DG_LOG_DOMAIN=\"GLib-GIO\" -DTEST_SERVICES=\""$(abs_top_builddir)/gio/tests/services"\"
+AM_CFLAGS = $(GLIB_WARN_CFLAGS)
 
-test_progs =                   \
-       io-stream               \
-       memory-input-stream     \
-       memory-output-stream    \
-       readwrite               \
-       g-file                  \
-       g-file-info             \
-       converter-stream        \
-       data-input-stream       \
-       data-output-stream      \
-       g-icon                  \
-       buffered-input-stream   \
-       buffered-output-stream  \
-       sleepy-stream           \
-       filter-streams          \
-       volumemonitor           \
-       simple-async-result     \
-       srvtarget               \
-       contexts                \
-       gsettings               \
-       gschema-compile         \
-       async-close-output-stream \
-       gdbus-addresses         \
-       network-address         \
-       gdbus-message           \
-       socket                  \
-       pollable                \
-       tls-certificate         \
-       tls-interaction         \
-       cancellable             \
-       vfs                     \
-       network-monitor         \
-       fileattributematcher    \
-       resources               \
-       proxy-test              \
-       simple-proxy            \
-       inet-address            \
-       permission              \
-       task                    \
-       credentials             \
+test_programs = \
+       io-stream                               \
+       memory-input-stream                     \
+       memory-output-stream                    \
+       readwrite                               \
+       g-file                                  \
+       g-file-info                             \
+       converter-stream                        \
+       data-input-stream                       \
+       data-output-stream                      \
+       g-icon                                  \
+       buffered-input-stream                   \
+       buffered-output-stream                  \
+       sleepy-stream                           \
+       filter-streams                          \
+       volumemonitor                           \
+       simple-async-result                     \
+       srvtarget                               \
+       contexts                                \
+       gsettings                               \
+       gschema-compile                         \
+       async-close-output-stream               \
+       gdbus-addresses                         \
+       network-address                         \
+       gdbus-message                           \
+       socket                                  \
+       pollable                                \
+       tls-certificate                         \
+       tls-interaction                         \
+       cancellable                             \
+       vfs                                     \
+       network-monitor                         \
+       fileattributematcher                    \
+       resources                               \
+       proxy-test                              \
+       simple-proxy                            \
+       inet-address                            \
+       permission                              \
+       task                                    \
+       credentials                             \
        $(NULL)
 
-if HAVE_DBUS_DAEMON
-test_progs +=                  \
-       actions                 \
-       gdbus-connection        \
-       gdbus-connection-loss   \
-       gdbus-connection-slow   \
-       gdbus-names             \
-       gdbus-proxy             \
-       gdbus-proxy-threads     \
-       gdbus-proxy-well-known-name \
-       gdbus-introspection     \
-       gdbus-threading         \
-       gdbus-export            \
-       gdbus-error             \
-       gdbus-bz627724          \
-       gmenumodel              \
+uninstalled_test_programs = \
        $(NULL)
-endif
 
-if OS_UNIX
-test_progs +=                  \
-       gdbus-close-pending     \
-       gdbus-connection-flush  \
-       gdbus-peer              \
-       gdbus-exit-on-close     \
-       gdbus-non-socket        \
-       gdbus-peer-object-manager \
-       appinfo                 \
-       contenttype             \
-       mimeapps                \
-       file                    \
+dist_test_data = \
+       $(wildcard cert-tests/*)                \
+       $(wildcard schema-tests/*)              \
+       org.gtk.test.gschema.xml                \
+       org.gtk.schemasourcecheck.gschema.xml   \
+       testenum.h                              \
+       enums.xml.template                      \
+       contexts.c                              \
+       g-icon.c                                \
        $(NULL)
-endif
 
-SAMPLE_PROGS =                                 \
-       resolver                        \
-       socket-server                   \
-       socket-client                   \
-       echo-server                     \
-       httpd                           \
-       send-data                       \
-       filter-cat                      \
-       gdbus-example-export            \
-       gdbus-example-own-name          \
-       gdbus-example-watch-name        \
-       gdbus-example-watch-proxy       \
-       gdbus-example-server            \
-       gdbus-example-subtree           \
-       gdbus-example-peer              \
-       gdbus-example-proxy-subclass    \
-       proxy                           \
-       gapplication-example-open       \
-       gapplication-example-cmdline    \
-       gapplication-example-cmdline2   \
-       gapplication-example-cmdline3   \
-       gapplication-example-actions    \
-       gapplication-example-dbushooks  \
-       gdbus-daemon                    \
+test_data = \
+       test.gresource                          \
+       $(NULL)
+
+noinst_PROGRAMS += \
+       resolver                                \
+       socket-server                           \
+       socket-client                           \
+       echo-server                             \
+       httpd                                   \
+       send-data                               \
+       filter-cat                              \
+       gdbus-example-export                    \
+       gdbus-example-own-name                  \
+       gdbus-example-watch-name                \
+       gdbus-example-watch-proxy               \
+       gdbus-example-server                    \
+       gdbus-example-subtree                   \
+       gdbus-example-peer                      \
+       gdbus-example-proxy-subclass            \
+       proxy                                   \
+       gapplication-example-open               \
+       gapplication-example-cmdline            \
+       gapplication-example-cmdline2           \
+       gapplication-example-cmdline3           \
+       gapplication-example-actions            \
+       gapplication-example-dbushooks          \
+       gdbus-daemon                            \
        $(NULL)
 
-other_progs =                          \
-       gdbus-testserver                \
-       gdbus-connection-flush-helper   \
+test_extra_programs = \
+       gdbus-testserver                        \
+       gdbus-connection-flush-helper           \
        $(NULL)
-noinst_PROGRAMS += $(other_progs)
 
 if OS_UNIX
-test_progs +=                  \
-       live-g-file             \
-       desktop-app-info        \
-       unix-fd                 \
-       unix-streams            \
-       gapplication            \
-       basic-application       \
-       gdbus-test-codegen      \
-       socket-address          \
+test_programs += \
+       live-g-file                             \
+       unix-fd                                 \
+       unix-streams                            \
+       gapplication                            \
+       basic-application                       \
+       gdbus-test-codegen                      \
+       socket-address                          \
+       gdbus-close-pending                     \
+       gdbus-connection-flush                  \
+       gdbus-peer                              \
+       gdbus-exit-on-close                     \
+       gdbus-non-socket                        \
+       gdbus-peer-object-manager               \
+       contenttype                             \
+       mimeapps                                \
+       file                                    \
+       $(NULL)
+
+# Uninstalled because of the check-for-executable logic in DesktopAppInfo unable to find the installed 
executable
+uninstalled_test_programs += \
+       appinfo                                 \
+       desktop-app-info                        \
+       $(NULL)
+
+test_data += \
+       appinfo-test.desktop                    \
+       appinfo-test2.desktop                   \
+       appinfo-test-gnome.desktop              \
+       appinfo-test-notgnome.desktop           \
+       file.c                                  \
        $(NULL)
 
-other_progs +=                                 \
+test_extra_programs += \
        appinfo-test                            \
        $(NULL)
 
-SAMPLE_PROGS +=                                        \
-       gdbus-example-unix-fd-client            \
-       gdbus-example-objectmanager-server      \
-       gdbus-example-objectmanager-client      \
+noinst_PROGRAMS += \
+       gdbus-example-unix-fd-client            \
+       gdbus-example-objectmanager-server      \
+       gdbus-example-objectmanager-client      \
        gdbus-test-fixture                      \
        $(NULL)
 endif
 
+if HAVE_DBUS_DAEMON
+test_programs += \
+       actions                                 \
+       gdbus-connection                        \
+       gdbus-connection-loss                   \
+       gdbus-connection-slow                   \
+       gdbus-names                             \
+       gdbus-proxy                             \
+       gdbus-proxy-threads                     \
+       gdbus-proxy-well-known-name             \
+       gdbus-introspection                     \
+       gdbus-threading                         \
+       gdbus-export                            \
+       gdbus-error                             \
+       gdbus-bz627724                          \
+       gmenumodel                              \
+       $(NULL)
+endif
+
 if OS_WIN32
-TEST_PROGS += win32-streams
+test_programs += win32-streams
 endif
 
 if PLATFORM_WIN32
 no_undefined = -no-undefined
 endif
 
-actions_SOURCES   = actions.c gdbus-sessionbus.c gdbus-sessionbus.h
-
-unix_streams_LDADD       = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-win32_streams_LDADD      = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-resolver_LDADD           = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-socket_server_LDADD      = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-socket_client_SOURCES    = socket-client.c \
-                            gtlsconsoleinteraction.c \
-                            gtlsconsoleinteraction.h
-socket_client_LDADD      = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-echo_server_LDADD        = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-httpd_LDADD              = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-send_data_LDADD                  = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
-contexts_LDADD           = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
+actions_SOURCES = actions.c gdbus-sessionbus.c gdbus-sessionbus.h
+socket_client_SOURCES = \
+       socket-client.c                 \
+       gtlsconsoleinteraction.c        \
+       gtlsconsoleinteraction.h
 
 gdbus_daemon_SOURCES = gdbus-daemon.c $(top_srcdir)/gio/gdbusdaemon.c 
$(top_builddir)/gio/gdbus-daemon-generated.c
 
 gdbus_testserver_SOURCES = gdbus-testserver.c
 
 if HAVE_DBUS1
-test_progs += gdbus-serialization
+test_programs += gdbus-serialization
 gdbus_serialization_SOURCES = gdbus-serialization.c gdbus-tests.h gdbus-tests.c
 gdbus_serialization_CFLAGS = $(AM_CFLAGS) $(DBUS1_CFLAGS)
 gdbus_serialization_LDADD = $(LDADD) $(DBUS1_LIBS)
 endif
 
-test_progs += gdbus-auth
+test_programs += gdbus-auth
 gdbus_auth_SOURCES = gdbus-auth.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
 gdbus_auth_LDADD = $(LDADD)
 
@@ -268,6 +248,7 @@ gdbus_names_SOURCES = gdbus-names.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-
 
 gdbus_proxy_SOURCES = gdbus-proxy.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
 
+gdbus_proxy_threads_CFLAGS = $(AM_CFLAGS) $(DBUS1_CFLAGS)
 gdbus_proxy_threads_SOURCES = gdbus-proxy-threads.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h 
gdbus-tests.c
 
 gdbus_proxy_well_known_name_SOURCES = gdbus-proxy-well-known-name.c gdbus-sessionbus.c gdbus-sessionbus.h 
gdbus-tests.h gdbus-tests.c
@@ -299,107 +280,12 @@ gapplication_SOURCES = gapplication.c gdbus-sessionbus.h gdbus-sessionbus.c gdbu
 
 gmenumodel_SOURCES = gmenumodel.c gdbus-sessionbus.h gdbus-sessionbus.c
 
-TEST_PROGS += $(test_progs)
-
 TESTS_ENVIRONMENT = \
        GLIB_MKENUMS=../../gobject/glib-mkenums \
        GLIB_COMPILE_SCHEMAS=../glib-compile-schemas
 
-schema_tests = \
-       array-default-not-in-choices.gschema.xml        \
-       bad-choice.gschema.xml                          \
-       bad-key.gschema.xml                             \
-       bad-key2.gschema.xml                            \
-       bad-key3.gschema.xml                            \
-       bad-key4.gschema.xml                            \
-       bad-type.gschema.xml                            \
-       bare-alias.gschema.xml                          \
-       choice-alias.gschema.xml                        \
-       choice-bad.gschema.xml                          \
-       choice-badtype.gschema.xml                      \
-       choice-invalid-alias.gschema.xml                \
-       choice-missing-value.gschema.xml                \
-       choice-shadowed-alias.gschema.xml               \
-       choice-upside-down.gschema.xml                  \
-       choice.gschema.xml                              \
-       choices-wrong-type.gschema.xml                  \
-       default-in-aliases.gschema.xml                  \
-       default-not-in-choices.gschema.xml              \
-       default-out-of-range.gschema.xml                \
-       empty-key.gschema.xml                           \
-       enum-with-aliases.gschema.xml                   \
-       enum-with-bad-default.gschema.xml               \
-       enum-with-chained-alias.gschema.xml             \
-       enum-with-choice.gschema.xml                    \
-       enum-with-invalid-alias.gschema.xml             \
-       enum-with-repeated-alias.gschema.xml            \
-       enum-with-repeated-nick.gschema.xml             \
-       enum-with-repeated-value.gschema.xml            \
-       enum-with-shadow-alias.gschema.xml              \
-       enum.gschema.xml                                \
-       flags-aliased-default.gschema.xml               \
-       flags-bad-default.gschema.xml                   \
-       flags-more-than-one-bit.gschema.xml             \
-       flags-with-enum-attr.gschema.xml                \
-       flags-with-enum-tag.gschema.xml                 \
-       extend-and-shadow-indirect.gschema.xml          \
-       extend-and-shadow.gschema.xml                   \
-       extend-missing.gschema.xml                      \
-       extend-nonlist.gschema.xml                      \
-       extend-self.gschema.xml                         \
-       extend-wrong-list-indirect.gschema.xml          \
-       extend-wrong-list.gschema.xml                   \
-       extending.gschema.xml                           \
-       from-docs.gschema.xml                           \
-       incomplete-list.gschema.xml                     \
-       inherit-gettext-domain.gschema.xml              \
-       invalid-path.gschema.xml                        \
-       key-in-list-indirect.gschema.xml                \
-       key-in-list.gschema.xml                         \
-       list-of-missing.gschema.xml                     \
-       missing-quotes.gschema.xml                              \
-       no-default.gschema.xml                          \
-       overflow.gschema.xml                            \
-       override-missing.gschema.xml                    \
-       override-range-error.gschema.xml                \
-       override-then-key.gschema.xml                   \
-       override-twice.gschema.xml                      \
-       override-type-error.gschema.xml                 \
-       override.gschema.xml                            \
-       range-badtype.gschema.xml                       \
-       range-default-high.gschema.xml                  \
-       range-default-low.gschema.xml                   \
-       range-high-default.gschema.xml                  \
-       range-low-default.gschema.xml                   \
-       range-missing-max.gschema.xml                   \
-       range-missing-min.gschema.xml                   \
-       range-parse-error.gschema.xml                   \
-       range-wrong-type.gschema.xml                    \
-       range.gschema.xml                               \
-       wrong-category.gschema.xml                      \
-       $(NULL)
-
-schema_test_files = $(addprefix schema-tests/,$(schema_tests))
-
-proxy_LDADD   = $(LDADD) \
-       $(top_builddir)/gthread/libgthread-2.0.la
-
 tls_certificate_SOURCES = tls-certificate.c gtesttlsbackend.c gtesttlsbackend.h
 
-cert_tests =                   \
-       cert1.pem               \
-       cert2.pem               \
-       cert3.pem               \
-       cert-key.pem            \
-       cert-list.pem           \
-       key8.pem                \
-       key-cert.pem            \
-       key.pem                 \
-       nothing.pem             \
-       $(NULL)
-
-cert_test_files = $(addprefix cert-tests/,$(cert_tests))
-
 # -----------------------------------------------------------------------------
 
 if OS_UNIX
@@ -421,13 +307,6 @@ endif OS_UNIX
 
 # -----------------------------------------------------------------------------
 
-desktop_test_files = \
-       appinfo-test.desktop                    \
-       appinfo-test2.desktop                   \
-       appinfo-test-gnome.desktop              \
-       appinfo-test-notgnome.desktop           \
-       $(NULL)
-
 EXTRA_DIST += \
        socket-common.c                 \
        org.gtk.test.gschema.xml        \
@@ -471,14 +350,18 @@ plugin_resources.c: test4.gresource.xml Makefile $(shell $(glib_compile_resource
 test.gresource: test.gresource.xml Makefile $(shell $(glib_compile_resources) --sourcedir=$(srcdir) 
--generate-dependencies $(srcdir)/test.gresource.xml)
        $(AM_V_GEN) $(glib_compile_resources) --target=$@ --sourcedir=$(srcdir) $<
 
-if BUILDOPT_INSTALL_TESTS
-insttest_LTLIBRARIES = libresourceplugin.la
+if ENABLE_INSTALLED_TESTS
+installed_test_LTLIBRARIES = libresourceplugin.la
 else
+if ENABLE_ALWAYS_BUILD_TESTS
 noinst_LTLIBRARIES = libresourceplugin.la
+else
+check_LTLIBRARIES = libresourceplugin.la
+endif
 endif
 
 libresourceplugin_la_SOURCES = resourceplugin.c plugin_resources.c
-libresourceplugin_la_LDFLAGS = -avoid-version -module $(no_undefined) -rpath $(insttestdir)
+libresourceplugin_la_LDFLAGS = -avoid-version -module $(no_undefined)
 libresourceplugin_la_LIBADD = $(LDADD)
 
 CLEANFILES = gdbus-test-codegen-generated.[ch] gdbus-test-codegen-generated-doc-*.xml test_resources2.[ch] 
plugin_resources.c
@@ -491,55 +374,8 @@ DISTCLEANFILES = \
        test.gresource                  \
        test_resources.c                \
        gsettings.store                 \
-       gschemas.compiled               \
+       gschemas.compiled               \
        schema-source/gschemas.compiled
 
 distclean-local:
        rm -rf xdgdatahome xdgdatadir
-
-test_files =                                   \
-       contexts.c                              \
-       g-icon.c                                \
-       file.c                                  \
-       enums.xml.template                      \
-       testenum.h                              \
-       org.gtk.test.gschema.xml                \
-       org.gtk.schemasourcecheck.gschema.xml   \
-       test.gresource                          \
-       $(NULL)
-EXTRA_DIST += $(test_files)
-
-if BUILDOPT_INSTALL_TESTS
-insttest_PROGRAMS = $(test_progs) $(other_progs)
-
-schematestdir = $(insttestdir)/schema-tests
-schematest_DATA = $(schema_test_files)
-
-certtestdir = $(insttestdir)/cert-tests
-certtest_DATA = $(cert_test_files)
-
-testdatadir = $(insttestdir)
-testdata_DATA = $(test_files)
-
-testmetadir = $(datadir)/installed-tests/$(PACKAGE)
-xfail_tests = desktop-app-info.test
-developer_only_tests = gsettings.test
-testmeta_DATA = $(filter-out $(xfail_tests) $(developer_only_tests),$(test_progs:=.test))
-
-%.test: %$(EXEEXT) Makefile
-       $(AM_V_GEN) (echo '[Test]' > $  tmp; \
-        echo 'Type=session' >> $  tmp; \
-        echo 'Exec=$(pkglibexecdir)/installed-tests/$<' >> $  tmp; \
-        mv $  tmp $@)
-
-%.desktop.insttest: %.desktop
-       sed -e s,Exec=./appinfo-test,Exec=$(insttestdir)/appinfo-test, < $< >$  tmp && mv $  tmp $@
-
-installed_desktop_test_files = $(desktop_test_files:.desktop=.desktop.insttest)
-install-data-local: $(installed_desktop_test_files)
-       for x in $(desktop_test_files); do \
-         install -m 0644 $${x}.insttest $(DESTDIR)$(testdatadir)/$$x; \
-       done
-       install -d -m 0755 $(DESTDIR)$(testdatadir)/schema-tests
-
-endif
diff --git a/gio/tests/gdbus-object-manager-example/Makefile.am 
b/gio/tests/gdbus-object-manager-example/Makefile.am
index 6875210..247b74a 100644
--- a/gio/tests/gdbus-object-manager-example/Makefile.am
+++ b/gio/tests/gdbus-object-manager-example/Makefile.am
@@ -1,24 +1,17 @@
+include $(top_srcdir)/Makefile.decl
 NULL =
 BUILT_SOURCES =
 CLEANFILES =
 
-include $(top_srcdir)/Makefile.decl
-
-AM_CPPFLAGS =                  \
-       -g                      \
-       $(gio_INCLUDES)         \
-       $(GLIB_DEBUG_FLAGS)     \
-       -I$(top_builddir)/gio   \
-       -I$(top_srcdir)/gio     \
-       -DSRCDIR=\""$(srcdir)"\"
+AM_CPPFLAGS = -g $(gio_INCLUDES) $(GLIB_DEBUG_FLAGS) -I$(top_builddir)/gio -I$(top_srcdir)/gio
 
 # ------------------------------------------------------------------------
 
-GDBUS_GENERATED =                                                                              \
-       gdbus-example-objectmanager-generated.h                                                 \
-       gdbus-example-objectmanager-generated.c                                                 \
+GDBUS_GENERATED = \
+       gdbus-example-objectmanager-generated.h                                                 \
+       gdbus-example-objectmanager-generated.c                                                 \
        gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Animal.xml    \
-       gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Cat.xml       \
+       gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Cat.xml       \
        $(NULL)
 
 $(GDBUS_GENERATED) : gdbus-example-objectmanager.xml Makefile 
$(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen
@@ -36,8 +29,12 @@ $(GDBUS_GENERATED) : gdbus-example-objectmanager.xml Makefile $(top_builddir)/gi
 BUILT_SOURCES += $(GDBUS_GENERATED)
 
 noinst_LTLIBRARIES = libgdbus-example-objectmanager.la
-libgdbus_example_objectmanager_la_SOURCES  = gdbus-example-objectmanager-generated.h 
gdbus-example-objectmanager-generated.c
-libgdbus_example_objectmanager_la_LIBADD   =           \
+
+libgdbus_example_objectmanager_la_SOURCES = \
+       gdbus-example-objectmanager-generated.h         \
+       gdbus-example-objectmanager-generated.c
+
+libgdbus_example_objectmanager_la_LIBADD = \
        $(top_builddir)/glib/libglib-2.0.la             \
        $(top_builddir)/gobject/libgobject-2.0.la       \
        $(top_builddir)/gmodule/libgmodule-2.0.la       \
@@ -47,4 +44,3 @@ libgdbus_example_objectmanager_la_LIBADD   =          \
 EXTRA_DIST += gdbus-example-objectmanager.xml
 
 CLEANFILES += $(GDBUS_GENERATED)
-
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 0744a6c..8fcf1a5 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -35,11 +35,8 @@ else
 MAYBE_PCRE = pcre 
 endif
 
-SUBDIRS = libcharset $(PRINTF_SUBDIR) $(MAYBE_PCRE) update-pcre .
+SUBDIRS = libcharset $(PRINTF_SUBDIR) $(MAYBE_PCRE) update-pcre . tests
 DIST_SUBDIRS = libcharset gnulib pcre update-pcre tests
-if BUILD_MODULAR_TESTS
-SUBDIRS += tests 
-endif
 
 AM_CPPFLAGS =                          \
        $(glib_INCLUDES)                \
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index 5ee09dd..449dd37 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -1,78 +1,30 @@
 include $(top_srcdir)/Makefile.decl
 NULL =
 
-insttestdir=$(pkglibexecdir)/installed-tests
-
-bookmark_test_files = \
-       bookmarks/fail-01.xbel \
-       bookmarks/fail-02.xbel \
-       bookmarks/fail-03.xbel \
-       bookmarks/fail-04.xbel \
-       bookmarks/fail-05.xbel \
-       bookmarks/fail-06.xbel \
-       bookmarks/fail-07.xbel \
-       bookmarks/fail-08.xbel \
-       bookmarks/fail-09.xbel \
-       bookmarks/fail-10.xbel \
-       bookmarks/fail-11.xbel \
-       bookmarks/fail-12.xbel \
-       bookmarks/fail-13.xbel \
-       bookmarks/fail-14.xbel \
-       bookmarks/fail-15.xbel \
-       bookmarks/fail-16.xbel \
-       bookmarks/fail-17.xbel \
-       bookmarks/valid-01.xbel \
-       bookmarks/valid-02.xbel \
-       bookmarks/valid-03.xbel \
-       $(NULL)
+LDADD = $(top_builddir)/glib/libglib-2.0.la -lm
+AM_CPPFLAGS = -g $(glib_INCLUDES) $(GLIB_DEBUG_FLAGS)
+DEFS = -DG_LOG_DOMAIN=\"GLib\" -DEXEEXT=\"$(EXEEXT)\"
+AM_CFLAGS = $(GLIB_WARN_CFLAGS)
 
-markup_tests = \
-       fail-1 fail-2 fail-3 fail-4 fail-5 \
-       fail-6 fail-7 fail-8 fail-9 fail-10 \
-       fail-11 fail-12 fail-13 fail-14 fail-15 \
-       fail-16 fail-17 fail-18 fail-19 fail-20 \
-       fail-21 fail-22 fail-23 fail-24 fail-25 \
-       fail-26 fail-27 fail-28 fail-29 fail-30 \
-       fail-31 fail-32 fail-33 fail-34 fail-35 \
-       fail-36 fail-37 fail-38 fail-39 fail-40 \
-       fail-41 fail-42 fail-43 fail-44 fail-45 \
-       fail-46 fail-47 fail-48 fail-49 \
-       valid-1 valid-2 valid-3 valid-4 valid-5 \
-       valid-6 valid-7 valid-8 valid-9 valid-10 \
-       valid-11 valid-12 valid-13 valid-14 valid-15 \
+dist_test_data = \
+       $(wildcard bookmarks/*)         \
+       $(wildcard markups/*)           \
+       keyfiletest.ini                 \
+       pages.ini                       \
+       keyfile.c                       \
+       empty                           \
+       4096-random-bytes               \
        $(NULL)
 
-all_markup_test_files = $(addprefix markups/,$(markup_tests:=.gmarkup) $(markup_tests:=.expected))
-
-test_files = \
-       keyfiletest.ini         \
-       pages.ini               \
-       keyfile.c               \
-       empty                   \
-       4096-random-bytes       \
+dist_test_extra_scripts = \
+       echo-script                     \
        $(NULL)
 
-test_script_files = \
-       echo-script
-
-AM_CPPFLAGS =                          \
-       -g                              \
-       $(glib_INCLUDES)                \
-       -DG_LOG_DOMAIN=\"GLib\"         \
-       -DSRCDIR=\""$(srcdir)"\"        \
-       -DEXEEXT=\"$(EXEEXT)\"          \
-       $(GLIB_DEBUG_FLAGS)
-
-AM_CFLAGS = $(GLIB_WARN_CFLAGS)
-
-LDADD = $(top_builddir)/glib/libglib-2.0.la -lm
-
-TEST_PROGS +=                          \
-       1bit-emufutex                   \
-       gwakeup                         \
+test_extra_programs = \
+       test-spawn-echo                 \
        $(NULL)
 
-all_test_programs =                    \
+test_programs = \
        array-test                      \
        asyncqueue                      \
        atomic                          \
@@ -130,7 +82,7 @@ all_test_programs =                  \
        spawn-singlethread              \
        strfuncs                        \
        string                          \
-       testing                         \
+       testing                         \
        test-printf                     \
        thread                          \
        timeout                         \
@@ -144,43 +96,24 @@ all_test_programs =                        \
        uri                             \
        1bit-mutex                      \
        642026                          \
-       642026-ec
+       642026-ec                       \
+       $(NULL)
 
 if OS_UNIX
-all_test_programs += unix
-all_test_programs += include
-endif
-
-extra_test_binaries = test-spawn-echo
-
-if BUILD_MODULAR_TESTS
-TEST_PROGS += $(all_test_programs)
-noinst_PROGRAMS = $(TEST_PROGS) $(extra_test_binaries)
+test_programs += unix include
 endif
 
-if BUILDOPT_INSTALL_TESTS
-insttest_PROGRAMS = $(all_test_programs) $(extra_test_binaries)
-testmetadir = $(datadir)/installed-tests/$(PACKAGE)
-testmeta_DATA = $(all_test_programs:=.test)
-
-testdatadir=$(insttestdir)
-testdata_DATA = $(test_files)
-
-testdata_SCRIPTS = $(test_script_files)
-
-bookmarksdir=$(insttestdir)/bookmarks
-bookmarks_DATA = $(bookmark_test_files)
+uninstalled_test_programs = \
+       1bit-emufutex                   \
+       gwakeup                         \
+       $(NULL)
 
-markupsdir=$(insttestdir)/markups
-markups_DATA = $(all_markup_test_files)
+if HAVE_EVENTFD
+uninstalled_test_programs += gwakeup-fallback
+gwakeup_fallback_SOURCES = gwakeuptest.c ../../glib/gwakeup.c
+gwakeup_fallback_CFLAGS = $(AM_CFLAGS) -DTEST_EVENTFD_FALLBACK
 endif
 
-%.test: %$(EXEEXT) Makefile
-       $(AM_V_GEN) (echo '[Test]' > $  tmp; \
-        echo 'Type=session' >> $  tmp; \
-        echo 'Exec=$(pkglibexecdir)/installed-tests/$<' >> $  tmp; \
-        mv $  tmp $@)
-
 atomic_CFLAGS  = $(AM_CFLAGS)
 if HAVE_GCC
 atomic_CFLAGS += -Wstrict-aliasing=2
@@ -194,12 +127,6 @@ endif
 
 gwakeup_SOURCES = gwakeuptest.c ../../glib/gwakeup.c
 
-if HAVE_EVENTFD
-TEST_PROGS += gwakeup-fallback
-gwakeup_fallback_SOURCES = gwakeuptest.c ../../glib/gwakeup.c
-gwakeup_fallback_CFLAGS = $(AM_CFLAGS) -DTEST_EVENTFD_FALLBACK
-endif
-
 if OS_UNIX
 
 # some testing of gtester functionality
@@ -215,13 +142,6 @@ private_LDFLAGS = @G_THREAD_LIBS@
 
 endif
 
-CLEANFILES = \
-       tmpsample.xml
+CLEANFILES = tmpsample.xml
 
-EXTRA_DIST += \
-       $(bookmark_test_files)  \
-       $(all_markup_test_files) \
-       $(test_files)           \
-       $(test_script_files)    \
-       bookmarks.xbel          \
-       $(NULL)
+EXTRA_DIST += bookmarks.xbel
diff --git a/gobject/Makefile.am b/gobject/Makefile.am
index d1b52d1..e84d938 100644
--- a/gobject/Makefile.am
+++ b/gobject/Makefile.am
@@ -4,10 +4,7 @@
 ## Process this file with automake to produce Makefile.in
 include $(top_srcdir)/Makefile.decl
 
-SUBDIRS = .
-if BUILD_MODULAR_TESTS
-SUBDIRS += tests 
-endif
+SUBDIRS = . tests
 
 BUILT_SOURCES=
 CLEANFILES=
diff --git a/gobject/tests/Makefile.am b/gobject/tests/Makefile.am
index 988a139..5bff6b3 100644
--- a/gobject/tests/Makefile.am
+++ b/gobject/tests/Makefile.am
@@ -1,12 +1,9 @@
 include $(top_srcdir)/Makefile.decl
 NULL =
 
-AM_CPPFLAGS =                                  \
-       -g                                      \
-       -DG_LOG_DOMAIN=\"GLib-GObject\"         \
-       $(gobject_INCLUDES)                     \
-       $(GLIB_DEBUG_FLAGS)
-
+LDADD = ../libgobject-2.0.la $(top_builddir)/glib/libglib-2.0.la
+AM_CPPFLAGS = -g $(gobject_INCLUDES) $(GLIB_DEBUG_FLAGS)
+DEFS = -DG_LOG_DOMAIN=\"GLib-GObject\"
 AM_CFLAGS = $(GLIB_WARN_CFLAGS)
 
 if CROSS_COMPILING
@@ -15,10 +12,7 @@ else
   glib_genmarshal=$(top_builddir)/gobject/glib-genmarshal
 endif
 
-noinst_PROGRAMS  = $(TEST_PROGS)
-LDADD = ../libgobject-2.0.la $(top_builddir)/gthread/libgthread-2.0.la $(top_builddir)/glib/libglib-2.0.la
-
-TEST_PROGS +=          \
+test_programs = \
        qdata           \
        boxed           \
        enums           \
@@ -48,19 +42,3 @@ CLEANFILES = marshalers.h marshalers.c
 ifaceproperties_SOURCES = ifaceproperties.c testcommon.h
 
 EXTRA_DIST += marshalers.list
-
-if BUILDOPT_INSTALL_TESTS
-insttestdir = $(pkglibexecdir)/installed-tests
-insttest_PROGRAMS = $(TEST_PROGS)
-
-testmetadir = $(datadir)/installed-tests/$(PACKAGE)
-testmeta_DATA = $(TEST_PROGS:=.test)
-
-%.test: %$(EXEEXT) Makefile
-       $(AM_V_GEN) (echo '[Test]' > $  tmp; \
-        echo 'Type=session' >> $  tmp; \
-        echo 'Exec=$(pkglibexecdir)/installed-tests/$<' >> $  tmp; \
-        mv $  tmp $@)
-
-
-endif
diff --git a/m4macros/glibtests.m4 b/m4macros/glibtests.m4
new file mode 100644
index 0000000..c868802
--- /dev/null
+++ b/m4macros/glibtests.m4
@@ -0,0 +1,28 @@
+dnl GLIB_TESTS
+dnl
+
+AC_DEFUN([GLIB_TESTS],
+[
+  AC_ARG_ENABLE(installed-tests,
+                AS_HELP_STRING([--enable-installed-tests],
+                               [Enable installation of some test cases]),
+                [case ${enableval} in
+                  yes) ENABLE_INSTALLED_TESTS="1"  ;;
+                  no)  ENABLE_INSTALLED_TESTS="" ;;
+                  *) AC_MSG_ERROR([bad value ${enableval} for --enable-installed-tests]) ;;
+                 esac])
+  AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test x$ENABLE_INSTALLED_TESTS == x1)
+  AC_ARG_ENABLE(always-build-tests,
+                AS_HELP_STRING([--enable-always-build-tests],
+                               [Enable always building tests during 'make all']),
+                [case ${enableval} in
+                  yes) ENABLE_ALWAYS_BUILD_TESTS="1"  ;;
+                  no)  ENABLE_ALWAYS_BUILD_TESTS="" ;;
+                  *) AC_MSG_ERROR([bad value ${enableval} for --enable-always-build-tests]) ;;
+                 esac])
+  AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test x$ENABLE_ALWAYS_BUILD_TESTS == x1)
+  if test x$ENABLE_INSTALLED_TESTS == x1; then
+    AC_SUBST(installed_test_metadir, [${datadir}/installed-tests/]AC_PACKAGE_NAME)
+    AC_SUBST(installed_testdir, [${libexecdir}/installed-tests/]AC_PACKAGE_NAME)
+  fi
+])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5a342c5..2e09775 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,95 +1,31 @@
 include $(top_srcdir)/Makefile.decl
+NULL =
 
-insttestdir = $(pkglibexecdir)/installed-tests
-
-SUBDIRS=gobject refcount
-
-AM_CPPFLAGS = \
-       $(gmodule_INCLUDES)                     \
-       -DGLIB_DISABLE_DEPRECATION_WARNINGS     \
-       -DG_LOG_DOMAIN=\"GLib\"                 \
-       -DSRCDIR=\"$(srcdir)\"                  \
-       $(GLIB_DEBUG_FLAGS)
+SUBDIRS = gobject refcount
 
+LDADD = $(top_builddir)/glib/libglib-2.0.la
+AM_CPPFLAGS = $(gmodule_INCLUDES) $(GLIB_DEBUG_FLAGS)
+DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\"
 AM_CFLAGS = -g
 
-EFENCE=
-
-libglib = $(top_builddir)/glib/libglib-2.0.la
-libgthread = $(top_builddir)/gthread/libgthread-2.0.la
-libgmodule = $(top_builddir)/gmodule/libgmodule-2.0.la
-libgobject = $(top_builddir)/gobject/libgobject-2.0.la
-
-libadd_libgmodule = $(libgmodule)
-libadd_libglib = $(libglib)
-if PLATFORM_WIN32
-no_undefined = -no-undefined
-
-module_test_exp = module-test.exp
-
-module-test.exp: module-test.o
-       $(DLLTOOL) --output-exp module-test.exp module-test.o
-
-spawn_test_win32_gui = spawn-test-win32-gui
-
-spawn_test_win32_gui_LDFLAGS = -mwindows
-
-endif
-
-EXTRA_DIST +=                                  \
-       $(test_scripts)                         \
-       makefile.msc.in                         \
-       casefold.txt                            \
-       casemap.txt                             \
-       gen-casefold-txt.pl                     \
-       gen-casemap-txt.pl                      \
-       iochannel-test-infile                   \
-       utf8.txt                                \
-       timeloop-basic.c                        \
-       assert-msg-test.gdb
-
-BUILT_EXTRA_DIST =                             \
-       makefile.msc
-
-if HAVE_CXX
-CXX_TEST = cxx-test
-cxx_test_LDADD = $(progs_ldadd)
-cxx_test_SOURCES = cxx-test.C
-else
-CXX_TEST =
-endif
+# Some random programs that appear not to be testcases and not used from any testcases
+check_PROGRAMS += \
+       testgdateparser                         \
+       unicode-normalize                       \
+       $(NULL)
 
-if ENABLE_TIMELOOP
-timeloop = timeloop
-endif
-noinst_PROGRAMS = $(TEST_PROGS)        \
-       testgdate               \
-       testgdateparser         \
-       unicode-normalize       \
-       unicode-collate         \
-       $(timeloop)             \
-       assert-msg-test         \
-       datetime
-
-TEST_PROGS             += testglib
-testglib_SOURCES         = testglib.c
-testglib_LDADD          = $(libglib)
-
-
-testgdate_LDADD = $(libglib)
-testgdateparser_LDADD = $(libglib)
-unicode_normalize_LDADD = $(libglib)
-unicode_collate_LDADD = $(libglib)
-assert_msg_test_LDADD = $(libglib)
-if ENABLE_TIMELOOP
-timeloop_LDADD = $(libglib)
-endif
-datetime_LDADD = $(libglib)
+# So far, this is the only gtester-ified testcase here
+test_programs = \
+       testglib                                \
+       $(NULL)
 
-test_programs =                                        \
+# These are not yet gtester-ified, so mark them as for 'installed' only so we
+# don't run them under the framework.  We will handle them manually below.
+installed_test_programs = \
+       testgdate                               \
+       datetime                                \
        atomic-test                             \
        bit-test                                \
-       $(CXX_TEST)                             \
        child-test                              \
        completion-test                         \
        dirname-test                            \
@@ -104,117 +40,120 @@ test_programs =                                  \
        asyncqueue-test                         \
        qsort-test                              \
        relation-test                           \
-       slice-test                              \
-       slice-color                             \
        slice-concurrent                        \
        slice-threadinit                        \
        sources                                 \
        spawn-test                              \
-       $(spawn_test_win32_gui)                 \
        thread-test                             \
        threadpool-test                         \
        type-test                               \
        unicode-caseconv                        \
-       unicode-encoding
-
-test_scripts = run-collate-tests.sh run-assert-msg-test.sh
-
-test_script_support_programs = unicode-collate
-
-check_PROGRAMS = $(test_programs) $(test_script_support_programs)
-
-TESTS = $(test_programs) $(test_scripts)
-TESTS_ENVIRONMENT = srcdir=$(srcdir) \
-       LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset \
-       MALLOC_CHECK_=2 \
-        MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
-
-test_data =                            \
-       iochannel-test-infile           \
-       casemap.txt                     \
-       casefold.txt                    \
-       utf8.txt                        \
+       unicode-encoding                        \
        $(NULL)
 
-if BUILDOPT_INSTALL_TESTS
-insttest_PROGRAMS = $(test_programs)
-
-testmetadir = $(datadir)/installed-tests/$(PACKAGE)
-testmeta_DATA = $(test_programs:=.test)
-
-insttest_DATA = $(test_data)
+test_extra_programs = \
+       slice-test                              \
+       slice-color                             \
+       assert-msg-test                         \
+       unicode-collate                         \
+       $(NULL)
 
-%.test: %$(EXEEXT) Makefile
-       $(AM_V_GEN) (echo '[Test]' > $  tmp; \
-        echo 'Type=session' >> $  tmp; \
-        echo 'Exec=env G_TEST_DATA=$(pkglibexecdir)/installed-tests $(pkglibexecdir)/installed-tests/$<' >> 
$  tmp; \
-        mv $  tmp $@)
+# These don't appear to work installed and we don't want to run them under gtester either...
+dist_uninstalled_test_extra_scripts = \
+       run-collate-tests.sh                    \
+       run-assert-msg-test.sh                  \
+       $(NULL)
 
-endif
+test_data = \
+       iochannel-test-infile                   \
+       casemap.txt                             \
+       casefold.txt                            \
+       utf8.txt                                \
+       $(NULL)
 
-progs_ldadd = $(EFENCE) $(libglib) $(EFENCE)
-thread_ldadd = $(libgthread) $(G_THREAD_LIBS) $(progs_ldadd)
-module_ldadd = $(libgmodule) $(G_MODULE_LIBS) $(progs_ldadd)
-
-atomic_test_LDADD = $(progs_ldadd)
-bit_test_LDADD = $(progs_ldadd)
-child_test_LDADD = $(thread_ldadd)
-completion_test_LDADD = $(progs_ldadd)
-dirname_test_LDADD = $(progs_ldadd)
-file_test_LDADD = $(progs_ldadd)
-env_test_LDADD = $(progs_ldadd)
-gio_test_LDADD = $(progs_ldadd)
-iochannel_test_LDADD = $(progs_ldadd)
-mainloop_test_LDADD = $(thread_ldadd)
-mapping_test_LDADD = $(progs_ldadd)
-module_test_LDADD = $(module_ldadd) $(module_test_exp)
+# Run the 'installed' tests manually in-tree.
+# This will cause them to be built even if installed tests are disabled.
+check_PROGRAMS += $(installed_test_programs) $(installed_test_extra_programs)
+check_SCRIPTS += $(installed_test_scripts)
+TESTS = $(installed_test_programs) $(dist_uninstalled_test_extra_scripts)
+TESTS_ENVIRONMENT = \
+       LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset    \
+       MALLOC_CHECK_=2                                         \
+       MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
+
+module_test_LDADD = $(LDADD) $(top_builddir)/gmodule/libgmodule-2.0.la
 module_test_LDFLAGS = $(G_MODULE_LDFLAGS)
-onceinit_LDADD = $(thread_ldadd)
-asyncqueue_test_LDADD = $(thread_ldadd)
-qsort_test_LDADD = $(progs_ldadd)
-relation_test_LDADD = $(progs_ldadd)
 slice_test_SOURCES = slice-test.c memchunks.c
-slice_test_LDADD = $(thread_ldadd)
 slice_color_SOURCES = slice-color.c memchunks.c
-slice_color_LDADD = $(thread_ldadd)
-slice_concurrent_SOURCES = slice-concurrent.c
-slice_concurrent_LDADD = $(thread_ldadd)
-slice_threadinit_SOURCES = slice-threadinit.c
-slice_threadinit_LDADD = $(thread_ldadd)
-sources_LDADD = $(progs_ldadd)
-spawn_test_LDADD = $(progs_ldadd)
-thread_test_LDADD = $(thread_ldadd)
-threadpool_test_LDADD = $(thread_ldadd)
-type_test_LDADD = $(progs_ldadd)
-unicode_encoding_LDADD = $(progs_ldadd)
-unicode_caseconv_LDADD = $(progs_ldadd)
-
-if BUILDOPT_INSTALL_TESTS
-insttest_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
+slice_threadinit_LDADD = $(LDADD) $(top_builddir)/gthread/libgthread-2.0.la
+
+if ENABLE_INSTALLED_TESTS
+installed_test_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
 else
+if ENABLE_ALWAYS_BUILD_TESTS
 noinst_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
+else
+check_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
+endif
 endif
 
 libmoduletestplugin_a_la_SOURCES = libmoduletestplugin_a.c
-libmoduletestplugin_a_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath 
$(insttestdir)
+libmoduletestplugin_a_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined)
 libmoduletestplugin_a_la_LIBADD = $(G_MODULE_LIBS) $(libadd_libgmodule) $(libadd_libglib)
 
 libmoduletestplugin_b_la_SOURCES = libmoduletestplugin_b.c
-libmoduletestplugin_b_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath 
$(insttestdir)
+libmoduletestplugin_b_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined)
 libmoduletestplugin_b_la_LIBADD = $(G_MODULE_LIBS) $(libadd_libgmodule) $(libadd_libglib)
 
 dist-hook: $(BUILT_EXTRA_DIST)
-       files='$(BUILT_EXTRA_DIST)';                            \
-       for f in $$files; do                                    \
-         if test -f $$f; then d=.; else d=$(srcdir); fi;       \
-         cp $$d/$$f $(distdir) || exit 1; done
-       mkdir $(distdir)/collate;                               \
-       for f in $(srcdir)/collate/* ; do                       \
-          if test -f $$f; then cp $$f $(distdir)/collate; fi; done
+       files='$(BUILT_EXTRA_DIST)';                            \
+       for f in $$files; do                                    \
+         if test -f $$f; then d=.; else d=$(srcdir); fi;       \
+         cp $$d/$$f $(distdir) || exit 1;                      \
+       done
+       mkdir $(distdir)/collate;                               \
+       for f in $(srcdir)/collate/* ; do                       \
+         if test -f $$f; then cp $$f $(distdir)/collate; fi;   \
+       done
+
+if HAVE_CXX
+installed_test_programs += cxx-test
+cxx_test_SOURCES = cxx-test.C
+endif
+
+if ENABLE_TIMELOOP
+installed_test_programs += timeloop
+endif
+
+if PLATFORM_WIN32
+no_undefined = -no-undefined
+
+module_test_exp = module-test.exp
+
+module-test.exp: module-test.o
+       $(DLLTOOL) --output-exp module-test.exp module-test.o
+
+installed_test_programs += spawn-test-win32-gui
+
+spawn_test_win32_gui_LDFLAGS = -mwindows
+
+endif
+
+EXTRA_DIST += \
+       $(test_scripts)                         \
+       makefile.msc.in                         \
+       gen-casefold-txt.pl                     \
+       gen-casemap-txt.pl                      \
+       iochannel-test-infile                   \
+       timeloop-basic.c                        \
+       assert-msg-test.gdb
+
+BUILT_EXTRA_DIST =                             \
+       makefile.msc
 
 DISTCLEANFILES =               \
-       iochannel-test-outfile  \
-       file-test-get-contents  \
-       maptest                 \
-       mapchild                \
+       iochannel-test-outfile  \
+       file-test-get-contents  \
+       maptest         \
+       mapchild                \
        collate.out
diff --git a/tests/gobject/Makefile.am b/tests/gobject/Makefile.am
index e58b158..59e6b68 100644
--- a/tests/gobject/Makefile.am
+++ b/tests/gobject/Makefile.am
@@ -1,31 +1,51 @@
 include $(top_srcdir)/Makefile.decl
+NULL =
 
-AM_CPPFLAGS =                                  \
-       $(gmodule_INCLUDES)                     \
-       -DGLIB_DISABLE_DEPRECATION_WARNINGS     \
-       $(GLIB_DEBUG_FLAGS)
-
-libglib = $(top_builddir)/glib/libglib-2.0.la
-libgthread = $(top_builddir)/gthread/libgthread-2.0.la
-libgmodule = $(top_builddir)/gmodule/libgmodule-2.0.la
-libgobject = $(top_builddir)/gobject/libgobject-2.0.la
+LDADD = $(top_builddir)/glib/libglib-2.0.la $(top_builddir)/gobject/libgobject-2.0.la
+AM_CPPFLAGS = $(gmodule_INCLUDES) $(GLIB_DEBUG_FLAGS)
+DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\"
+AM_CFLAGS = -g
 
+# So far, only two gtester-ified cases
+test_programs = \
+       gvalue-test                             \
+       paramspec-test                          \
+       $(NULL)
 
-# libtool dependency tracking seems broken.  this is currently
-# required to get the tests to dynamic link against the in-tree
-# libglib instead of the system one
-libgobject += $(libglib)
+# These are not yet gtester-ified, so mark them as for 'installed' only so we
+# don't run them under the framework.  We will handle them manually below.
+installed_test_programs = \
+       deftype                                 \
+       accumulator                             \
+       defaultiface                            \
+       dynamictype                             \
+       override                                \
+       singleton                               \
+       references                              \
+       $(NULL)
 
-########################################################################
+# Don't install these ones, and keep them out of 'make check' because they take too long...
+noinst_PROGRAMS += \
+       performance                             \
+       performance-threaded                    \
+       $(NULL)
+
+# Run the 'installed' tests manually in-tree.
+# This will cause them to be built even if installed tests are disabled.
+check_PROGRAMS += $(installed_test_programs) $(installed_test_extra_programs)
+TESTS = $(installed_test_programs)
+TESTS_ENVIRONMENT = \
+       LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset    \
+       MALLOC_CHECK_=2                                         \
+       MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
 
-noinst_LTLIBRARIES = libtestgobject.la
+accumulator_SOURCES = accumulator.c testmarshal.c testmarshal.h
+defaultiface_SOURCES = defaultiface.c testmodule.c testmodule.h
+dynamictype_SOURCES = dynamictype.c testmodule.c testmodule.h
 
-libtestgobject_la_SOURCES =    \
-       testcommon.h            \
-       testmarshal.h           \
-       testmarshal.c           \
-       testmodule.c            \
-       testmodule.h
+if ENABLE_TIMELOOP
+installed_test_programs += timeloop-closure
+endif
 
 if CROSS_COMPILING
   glib_genmarshal=$(GLIB_GENMARSHAL)
@@ -48,60 +68,10 @@ testmarshal.c: @REBUILD@ testmarshal.h testmarshal.list $(glib_genmarshal)
 BUILT_SOURCES = testmarshal.h testmarshal.c
 CLEANFILES = stamp-testmarshal.h
 
-########################################################################
-
-LDADD = libtestgobject.la $(libgobject)
-
-test_programs =                                        \
-       deftype                                 \
-       gvalue-test                             \
-       paramspec-test                          \
-       accumulator                             \
-       defaultiface                            \
-       dynamictype                             \
-       override                                \
-       singleton                               \
-       references
-
-performance_programs =                                 \
-       performance                             \
-       performance-threaded
-
-performance_LDADD = $(libgobject) $(libgthread)
-performance_threaded_LDADD = $(libgobject) $(libgthread)
-check_PROGRAMS = $(test_programs)
-noinst_PROGRAMS = $(performance_programs) testgobject
-
-if ENABLE_TIMELOOP
-noinst_PROGRAMS += timeloop-closure
-endif
-
-TESTS = $(test_programs) $(performance_programs)
-TESTS_ENVIRONMENT = srcdir=$(srcdir) \
-       LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset \
-       MALLOC_CHECK_=2 \
-       MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
-
-if BUILDOPT_INSTALL_TESTS
-insttestdir = $(pkglibexecdir)/installed-tests
-insttest_PROGRAMS = $(test_programs)
-
-testmetadir = $(datadir)/installed-tests/$(PACKAGE)
-testmeta_DATA = $(test_programs:=.test)
-
-%.test: %$(EXEEXT) Makefile
-       $(AM_V_GEN) (echo '[Test]' > $  tmp; \
-        echo 'Type=session' >> $  tmp; \
-        echo 'Exec=env G_TEST_DATA=$(pkglibexecdir)/installed-tests $(pkglibexecdir)/installed-tests/$<' >> 
$  tmp; \
-        mv $  tmp $@)
-endif
-
-########################################################################
-
-EXTRA_DIST +=            \
+EXTRA_DIST += \
        testmarshal.list
 
-BUILT_EXTRA_DIST =                             \
+BUILT_EXTRA_DIST = \
        testmarshal.h                           \
        testmarshal.c
 
@@ -115,5 +85,3 @@ distclean-local:
        if test $(srcdir) = .; then :; else     \
            rm -f $(BUILT_EXTRA_DIST);          \
        fi
-
-
diff --git a/tests/refcount/Makefile.am b/tests/refcount/Makefile.am
index 34daca6..1bd3b70 100644
--- a/tests/refcount/Makefile.am
+++ b/tests/refcount/Makefile.am
@@ -1,17 +1,13 @@
 include $(top_srcdir)/Makefile.decl
+NULL =
 
-AM_CPPFLAGS =                                  \
-       $(gmodule_INCLUDES)                     \
-       -DGLIB_DISABLE_DEPRECATION_WARNINGS     \
-       $(GLIB_DEBUG_FLAGS)
+LDADD = $(top_builddir)/glib/libglib-2.0.la $(top_builddir)/gobject/libgobject-2.0.la
+AM_CPPFLAGS = $(gmodule_INCLUDES) $(GLIB_DEBUG_FLAGS)
+DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS
+AM_CFLAGS = -g
 
-libglib = $(top_builddir)/glib/libglib-2.0.la
-libgmodule = $(top_builddir)/gmodule/libgmodule-2.0.la
-libgobject = $(top_builddir)/gobject/libgobject-2.0.la
-
-LDADD = $(libglib) $(libgobject)
-
-test_programs =                                \
+# These are not gtester tests, so handle them manually
+TESTS = \
        closures                                \
        objects                                 \
        objects2                                \
@@ -22,9 +18,11 @@ test_programs =                              \
        signal1                                 \
        signal2                                 \
        signal3                                 \
-       signal4
-
+       signal4                                 \
+       $(NULL)
 
+TESTS_ENVIRONMENT = srcdir=$(srcdir) \
+       LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset
 
 signal1_SOURCES = signals.c
 signal1_CFLAGS = -DTESTNUM=1 $(AM_CFLAGS)
@@ -35,10 +33,4 @@ signal3_CFLAGS = -DTESTNUM=3 $(AM_CFLAGS)
 signal4_SOURCES = signals.c
 signal4_CFLAGS = -DTESTNUM=4 $(AM_CFLAGS)
 
-check_PROGRAMS = $(test_programs)
-
-all: $(check_PROGRAMS)
-
-TESTS = $(test_programs)
-TESTS_ENVIRONMENT = srcdir=$(srcdir) \
-       LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset
+check_PROGRAMS += $(TESTS)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]