initialize automake variables EXTRA_DIST and TEST_PROGS for unconditional
author21:06:47 Tim Janik <timj@imendio.com>
Wed, 21 Nov 2007 20:09:46 +0000 (20:09 +0000)
committerTim Janik <timj@src.gnome.org>
Wed, 21 Nov 2007 20:09:46 +0000 (20:09 +0000)
2007-11-21 21:06:47  Tim Janik  <timj@imendio.com>

* Makefile.decl: initialize automake variables EXTRA_DIST and
TEST_PROGS for unconditional appending via += in other makefiles.
define recursive test targets: test, test-report, perf-report,
full-report, as described here:
      http://mail.gnome.org/archives/gtk-devel-list/2007-November/msg00000.html

* Makefile.am:
* build/win32/vs8/Makefile.am, build/win32/dirent/Makefile.am:
* build/win32/Makefile.am, build/Makefile.am:
* docs/Makefile.am, docs/reference/Makefile.am:
* docs/reference/glib/Makefile.am, docs/reference/gobject/Makefile.am:
* gmodule/Makefile.am, tests/Makefile.am:
* tests/refcount/Makefile.am, tests/gobject/Makefile.am:
* glib/update-pcre/Makefile.am, glib/libcharset/Makefile.am:
* glib/tests/Makefile.am, glib/pcre/Makefile.am:
* glib/gnulib/Makefile.am, gobject/Makefile.am, m4macros/Makefile.am:
* gthread/Makefile.am, glib/Makefile.am:
include $(top_srcdir)/Makefile.decl, adapted EXTRA_DIST assignments.

* glib/tests/Makefile.am: removed example testing rules.

* glib/tests/testing.c: conditionalized performance and slow tests.

* glib/gtestutils.h:
* glib/gtestutils.c: work around g_test_config_vars not changing its
exported value after value assignments, aparently due to symbol aliases.

* glib/gtester.c: fixed off-by-one error which produced junk in logs.

* configure.in: check for python >= 2.4 and provide $PYTHON for scripts.

svn path=/trunk/; revision=5914

25 files changed:
ChangeLog
Makefile.am
Makefile.decl [new file with mode: 0644]
configure.in
docs/Makefile.am
docs/reference/Makefile.am
docs/reference/glib/Makefile.am
docs/reference/gobject/Makefile.am
glib/Makefile.am
glib/gnulib/Makefile.am
glib/gtester.c
glib/gtestutils.c
glib/gtestutils.h
glib/libcharset/Makefile.am
glib/pcre/Makefile.am
glib/tests/Makefile.am
glib/tests/testing.c
glib/update-pcre/Makefile.am
gmodule/Makefile.am
gobject/Makefile.am
gthread/Makefile.am
m4macros/Makefile.am
tests/Makefile.am
tests/gobject/Makefile.am
tests/refcount/Makefile.am

index 3a26c91..1ddca7c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2007-11-21 21:06:47  Tim Janik  <timj@imendio.com>
+
+       * Makefile.decl: initialize automake variables EXTRA_DIST and
+       TEST_PROGS for unconditional appending via += in other makefiles.
+       define recursive test targets: test, test-report, perf-report,
+       full-report, as described here:
+      http://mail.gnome.org/archives/gtk-devel-list/2007-November/msg00000.html
+
+       * Makefile.am:
+       * build/win32/vs8/Makefile.am, build/win32/dirent/Makefile.am:
+       * build/win32/Makefile.am, build/Makefile.am:
+       * docs/Makefile.am, docs/reference/Makefile.am:
+       * docs/reference/glib/Makefile.am, docs/reference/gobject/Makefile.am:
+       * gmodule/Makefile.am, tests/Makefile.am:
+       * tests/refcount/Makefile.am, tests/gobject/Makefile.am:
+       * glib/update-pcre/Makefile.am, glib/libcharset/Makefile.am:
+       * glib/tests/Makefile.am, glib/pcre/Makefile.am:
+       * glib/gnulib/Makefile.am, gobject/Makefile.am, m4macros/Makefile.am:
+       * gthread/Makefile.am, glib/Makefile.am:
+       include $(top_srcdir)/Makefile.decl, adapted EXTRA_DIST assignments.
+
+       * glib/tests/Makefile.am: removed example testing rules.
+
+       * glib/tests/testing.c: conditionalized performance and slow tests.
+
+       * glib/gtestutils.h:
+       * glib/gtestutils.c: work around g_test_config_vars not changing its
+       exported value after value assignments, aparently due to symbol aliases.
+
+       * glib/gtester.c: fixed off-by-one error which produced junk in logs.
+
+       * configure.in: check for python >= 2.4 and provide $PYTHON for scripts.
+
 Tue Nov 20 15:59:55 2007 +0100 Tim Janik
 
        Renamed gtestframework to gtestutils.
index f685cf2..e36285c 100644 (file)
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 AUTOMAKE_OPTIONS = 1.7
 
@@ -9,7 +10,7 @@ bin_SCRIPTS = glib-gettextize
 INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@ \
        -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION
 
-EXTRA_DIST                   \
+EXTRA_DIST +=                  \
        ChangeLog.pre-2-14      \
        ChangeLog.pre-2-12      \
        ChangeLog.pre-2-10      \
diff --git a/Makefile.decl b/Makefile.decl
new file mode 100644 (file)
index 0000000..2c061b3
--- /dev/null
@@ -0,0 +1,56 @@
+# GLIB - Library of useful C routines
+
+#GTESTER = gtester                     # for non-GLIB packages
+GTESTER = $(top_builddir)/glib/gtester # for the GLIB package
+
+# initialize variables for unconditional += appending
+EXTRA_DIST =
+TEST_PROGS =
+
+### testing rules
+
+# test: run all tests in cwd and subdirs
+test:  ${TEST_PROGS}
+       @test -z "${TEST_PROGS}" || ${GTESTER} --verbose ${TEST_PROGS}
+       @ for subdir in $(SUBDIRS) ; do \
+           test "$$subdir" = "." -o "$$subdir" = "po" || \
+           ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+         done
+# test-report: run tests in subdirs and generate report
+# perf-report: run tests in subdirs with -m perf and generate report
+# full-report: like test-report: with -m perf and -m slow
+test-report perf-report full-report:   ${TEST_PROGS}
+       @test -z "${TEST_PROGS}" || { \
+         case $@ in \
+         test-report) test_options="-k";; \
+         perf-report) test_options="-k -m=perf";; \
+         full-report) test_options="-k -m=perf -m=slow";; \
+         esac ; \
+         if test -z "$$GTESTER_LOGDIR" ; then  \
+           ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
+         elif test -n "${TEST_PROGS}" ; then \
+           ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
+         fi ; \
+       }
+       @ ignore_logdir=true ; \
+         if test -z "$$GTESTER_LOGDIR" ; then \
+           GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
+           ignore_logdir=false ; \
+         fi ; \
+         for subdir in $(SUBDIRS) ; do \
+           test "$$subdir" = "." -o "$$subdir" = "po" || \
+           ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+         done ; \
+         $$ignore_logdir || { \
+           echo '<?xml version="1.0"?>' > $@.xml ; \
+           echo '<report-collection>'  >> $@.xml ; \
+           for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
+             sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
+           done ; \
+           echo >> $@.xml ; \
+           echo '</report-collection>' >> $@.xml ; \
+           rm -rf "$$GTESTER_LOGDIR"/ ; \
+         }
+.PHONY: test test-report perf-report full-report
+# run make test as part of make check
+check-local: test
index fb6f19f..adc3ab5 100644 (file)
@@ -366,6 +366,10 @@ if test "x$PERL_PATH" = x ; then
 fi
 AC_SUBST(PERL_PATH)
 
+# Need suitable python path for greport
+AM_PATH_PYTHON(2.4,,PYTHON="/usr/bin/env python2.4")
+
+
 dnl ***********************
 dnl *** Tests for iconv ***
 dnl ***********************
index c447936..2349f44 100644 (file)
@@ -1,8 +1,9 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 SUBDIRS = reference
 
-EXTRA_DIST = debugging.txt macros.txt
+EXTRA_DIST += debugging.txt macros.txt
 
 files:
        @files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \
index c5c7e96..7f2aab0 100644 (file)
@@ -1 +1,3 @@
+include $(top_srcdir)/Makefile.decl
+
 SUBDIRS = glib gobject
index ffa113f..97a3562 100644 (file)
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 AUTOMAKE_OPTIONS = 1.6
 
 # The name of the module.
index c1cc1f1..00ee0ea 100644 (file)
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 # The name of the module.
 DOC_MODULE=gobject
index 4f5822a..b77c29b 100644 (file)
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 if HAVE_GOOD_PRINTF
 else
@@ -52,7 +53,7 @@ MIRRORING_TAB_SOURCE =                                \
 
 # The compilation of GRegex can be disabled, but the source files must
 # be distributed.
-EXTRA_DIST                   \
+EXTRA_DIST +=                  \
        makefile.msc.in         \
        glib.rc.in              \
        gen-unicode-tables.pl   \
index 2387885..fb4ecfa 100644 (file)
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/glib -DG_LOG_DOMAIN=\"GLib\" \
        $(GLIB_DEBUG_FLAGS) -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION 
index 77028da..395970e 100644 (file)
@@ -65,8 +65,8 @@ static const char*
 sindent (guint n)
 {
   static const char spaces[] = "                                                                                                    ";
-  int l = sizeof (spaces);
-  n = MIN (n, l - 1);
+  int l = sizeof (spaces) - 1;
+  n = MIN (n, l);
   return spaces + l - n;
 }
 
index b275a68..8335a58 100644 (file)
@@ -83,13 +83,14 @@ static char       *test_trap_last_stderr = NULL;
 static char       *test_uri_base = NULL;
 static gboolean    test_debug_log = FALSE;
 static DestroyEntry *test_destroy_queue = NULL;
-const GTestConfig *g_test_config_vars = NULL;
 static GTestConfig mutable_test_config_vars = {
+  FALSE,        /* test_initialized */
   TRUE,         /* test_quick */
   FALSE,        /* test_perf */
   FALSE,        /* test_verbose */
   FALSE,        /* test_quiet */
 };
+const GTestConfig * const g_test_config_vars = &mutable_test_config_vars;
 
 /* --- functions --- */
 const char*
@@ -376,8 +377,8 @@ g_test_init (int    *argc,
   /* check caller args */
   g_return_if_fail (argc != NULL);
   g_return_if_fail (argv != NULL);
-  g_return_if_fail (g_test_config_vars == NULL);
-  g_test_config_vars = &mutable_test_config_vars;
+  g_return_if_fail (g_test_config_vars->test_initialized == FALSE);
+  mutable_test_config_vars.test_initialized = TRUE;
 
   va_start (args, argv);
   vararg1 = va_arg (args, gpointer); /* reserved for future extensions */
@@ -1009,7 +1010,7 @@ int
 g_test_run_suite (GTestSuite *suite)
 {
   guint n_bad = 0;
-  g_return_val_if_fail (g_test_config_vars != NULL, -1);
+  g_return_val_if_fail (g_test_config_vars->test_initialized, -1);
   g_return_val_if_fail (g_test_run_once == TRUE, -1);
   g_test_run_once = FALSE;
   if (!test_paths)
index 2b60b72..d2c9690 100644 (file)
@@ -67,6 +67,7 @@ void    g_test_init                     (int            *argc,
                                          ...);
 /* query testing framework config */
 #define g_test_quick()                  (g_test_config_vars->test_quick)
+#define g_test_slow()                   (!g_test_config_vars->test_quick)
 #define g_test_perf()                   (g_test_config_vars->test_perf)
 #define g_test_verbose()                (g_test_config_vars->test_verbose)
 #define g_test_quiet()                  (g_test_config_vars->test_quiet)
@@ -180,12 +181,13 @@ void    g_test_add_vtable               (const char     *testpath,
                                          void          (*data_test)     (void),
                                          void          (*data_teardown) (void));
 typedef struct {
+  gboolean      test_initialized;
   gboolean      test_quick;     /* disable thorough tests */
   gboolean      test_perf;      /* run performance tests */
   gboolean      test_verbose;   /* extra info */
   gboolean      test_quiet;     /* reduce output */
 } GTestConfig;
-GLIB_VAR const GTestConfig *g_test_config_vars;
+GLIB_VAR const GTestConfig * const g_test_config_vars;
 
 /* internal logging API */
 typedef enum {
index c019457..3cf4ab3 100644 (file)
@@ -1,4 +1,5 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES =                     \
        -DLIBDIR=\"$(libdir)\" -I$(top_srcdir)
@@ -9,7 +10,7 @@ libcharset_la_SOURCES =        \
        libcharset.h            \
        localcharset.c
 
-EXTRA_DIST                   \
+EXTRA_DIST +=                  \
        README                  \
        config.charset          \
        ref-add.sin             \
index c5aedb6..a9971a8 100644 (file)
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
 INCLUDES = \
        -DG_LOG_DOMAIN=\"GLib-GRegex\" \
        -DSUPPORT_UCP \
@@ -58,7 +60,7 @@ libpcre_la_LIBADD = $(DEP_LIBS)
 
 libpcre_la_LDFLAGS = -no-undefined
 
-EXTRA_DIST                           \
+EXTRA_DIST +=                          \
                COPYING                 \
                makefile.msc
 
index e2057a4..ad408f8 100644 (file)
@@ -1,8 +1,7 @@
-INCLUDES = -g -I$(top_srcdir) -I$(top_srcdir)/glib $(GLIB_DEBUG_FLAGS)
+include $(top_srcdir)/Makefile.decl
 
-GTESTER                 = $(top_builddir)/glib/gtester
+INCLUDES = -g -I$(top_srcdir) -I$(top_srcdir)/glib $(GLIB_DEBUG_FLAGS)
 
-TEST_PROGS     =
 noinst_PROGRAMS = $(TEST_PROGS)
 progs_ldadd     = $(top_builddir)/glib/libglib-2.0.la
 
@@ -11,15 +10,6 @@ TEST_PROGS       += testing
 testing_SOURCES          = testing.c
 testing_LDADD    = $(progs_ldadd)
 
-# exemplary unit test rules
-test:
-       ${GTESTER} --verbose ${TEST_PROGS}
-test-report:
-       ${GTESTER} --verbose -k -o testreport.xml ${TEST_PROGS}
-.PHONY: test test-report
-check-local: test
-
-
 # some testing of gtester funcitonality
 XMLLINT=xmllint
 gtester-xmllint-check: # check testreport xml with xmllint if present
index 3913f79..77aa787 100644 (file)
@@ -174,10 +174,12 @@ main (int   argc,
   g_test_add_func ("/random-generator/rand-2", test_rand2);
   g_test_add_func ("/misc/assertions", test_assertions);
   g_test_add ("/misc/primetoul", Fixturetest, fixturetest_setup, fixturetest_test, fixturetest_teardown);
-  g_test_add_func ("/misc/timer", test_timer);
+  if (g_test_perf())
+    g_test_add_func ("/misc/timer", test_timer);
   g_test_add_func ("/forking/fail assertion", test_fork_fail);
   g_test_add_func ("/forking/patterns", test_fork_patterns);
-  g_test_add_func ("/forking/timeout", test_fork_timeout);
+  if (g_test_slow())
+    g_test_add_func ("/forking/timeout", test_fork_timeout);
 
   return g_test_run();
 }
index ac7f82c..b7f80c6 100644 (file)
@@ -1,4 +1,6 @@
-EXTRA_DIST =                   \
+include $(top_srcdir)/Makefile.decl
+
+EXTRA_DIST +=                  \
        update.sh               \
        Makefile.am-1           \
        Makefile.am-2           \
index 84118bd..ab4b1f6 100644 (file)
@@ -1,9 +1,10 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/glib -I$(top_srcdir)/gmodule \
        -DG_LOG_DOMAIN=\"GModule\" @GLIB_DEBUG_FLAGS@ -DG_DISABLE_DEPRECATED
 
-EXTRA_DIST   \
+EXTRA_DIST +=  \
                makefile.msc.in \
                gmoduleconf.h.in \
                gmodule.def     \
index 6721ed5..7dfb276 100644 (file)
@@ -2,6 +2,7 @@
 # Copyright (C) 1997,98,99,2000 Tim Janik and Red Hat, Inc.
 #
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES = \
        -DG_LOG_DOMAIN=\"GLib-GObject\"         \
@@ -142,7 +143,7 @@ gobject_extra_sources = \
 gobject_target_headers = $(gobject_public_h_sources)
 gobject_target_sources = $(gobject_c_sources)
 EXTRA_HEADERS =
-EXTRA_DIST = \
+EXTRA_DIST += \
        $(gobject_private_h_sources)    \
        $(gobject_extra_sources)        \
        makegobjectalias.pl             \
index af8ea64..5d774d9 100644 (file)
@@ -1,10 +1,11 @@
 ## Process this file with automake to produce Makefile.in
+include $(top_srcdir)/Makefile.decl
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/glib -I$(top_srcdir)/gthread \
        -DG_LOG_DOMAIN=\"GThread\" @GTHREAD_COMPILE_IMPL_DEFINES@ \
        @GLIB_DEBUG_FLAGS@ -DG_DISABLE_DEPRECATED
 
-EXTRA_DIST                           \
+EXTRA_DIST +=                          \
                makefile.msc.in         \
                gthread-posix.c         \
                gthread-win32.c         \
index bf2fa8f..0284b4e 100644 (file)
@@ -1,7 +1,8 @@
+include $(top_srcdir)/Makefile.decl
 
 installed_m4= glib-2.0.m4 glib-gettext.m4
 
-EXTRA_DIST=$(installed_m4)
+EXTRA_DIST+=$(installed_m4)
 
 m4datadir = $(datadir)/aclocal
 m4data_DATA = $(installed_m4)
index 5bed3e4..acc7570 100644 (file)
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
 SUBDIRS=gobject refcount
 
 if ENABLE_REGEX
@@ -31,7 +33,7 @@ spawn_test_win32_gui_LDFLAGS = -mwindows
 
 endif
 
-EXTRA_DIST                                   \
+EXTRA_DIST +=                                  \
        $(test_scripts)                         \
        makefile.msc.in                         \
        casefold.txt                            \
index d81c7e7..d610366 100644 (file)
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
 INCLUDES =                                     \
        -I$(top_srcdir)                         \
        -I$(top_srcdir)/glib                    \
@@ -70,7 +72,7 @@ TESTS_ENVIRONMENT = srcdir=$(srcdir) \
 
 ########################################################################
 
-EXTRA_DIST             \
+EXTRA_DIST +=            \
        testmarshal.list
 
 BUILT_EXTRA_DIST =                             \
index bfb21c0..ff29b59 100644 (file)
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
 INCLUDES =                                     \
        -I$(top_srcdir)                         \
        -I$(top_srcdir)/glib                    \