AUDIT: r21724 - gnucash/trunk/src/test-core - [Testing] Export test-core log suppression functions to python and guile
John Ralls
jralls at code.gnucash.org
Mon Dec 12 17:41:42 EST 2011
Author: jralls
Date: 2011-12-12 17:41:41 -0500 (Mon, 12 Dec 2011)
New Revision: 21724
Trac: http://svn.gnucash.org/trac/changeset/21724
Added:
gnucash/trunk/src/test-core/test-stuff.i
gnucash/trunk/src/test-core/test-stuff.scm
Modified:
gnucash/trunk/src/test-core/Makefile.am
Log:
[Testing] Export test-core log suppression functions to python and guile
Enables silencing expected error output. Finally found the secret code
to get libtool to build a "noinst" dynamic library: pass -rpath as an
ldflag.
BP
Modified: gnucash/trunk/src/test-core/Makefile.am
===================================================================
--- gnucash/trunk/src/test-core/Makefile.am 2011-12-12 22:03:45 UTC (rev 21723)
+++ gnucash/trunk/src/test-core/Makefile.am 2011-12-12 22:41:41 UTC (rev 21724)
@@ -1,13 +1,99 @@
-noinst_LTLIBRARIES=libtest-core.la
+noinst_LTLIBRARIES = libtest-core.la
-libtest_core_la_SOURCES = test-stuff.c
-libtest_core_la_LDFLAGS = -module
+SWIG_FILES = test-stuff.i
+
+libtest_core_la_SOURCES = \
+ test-stuff.c
+
libtest_core_la_LIBADD = \
${GLIB_LIBS}
noinst_HEADERS=test-stuff.h
-AM_CPPFLAGS = \
+libtest_core_la_CPPFLAGS = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/libqof/qof \
${GLIB_CFLAGS}
+
+libtest_core_la_LDFLAGS = \
+ -rpath ${exec-prefix}/lib
+
+if BUILDING_FROM_SVN
+swig-test-stuff-guile.c: test-stuff.i $(top_srcdir)/src/base-typemaps.i
+ $(SWIG) -guile $(SWIG_ARGS) -Linkage module \
+ -I${top_srcdir}/src \
+ ${AM_CPPFLAGS} -o $@ $<
+
+swig-test-stuff-python.c: test-stuff.i $(top_srcdir)/src/base-typemaps.i
+ $(SWIG) -python -Wall -Werror $(SWIG_ARGS) \
+ -I${top_srcdir}/src \
+ ${AM_CPPFLAGS} -o $@ $<
+
+test-stuff.py: swig-test-stuff-python.c ${SWIG_FILES}
+endif
+noinst_LTLIBRARIES += libtest-core-guile.la
+libtest_core_guile_la_SOURCES = swig-test-stuff-guile.c
+libtest_core_guile_la_LIBADD = \
+ ${GUILE_LIBS} \
+ ${GLIB_LIBS} \
+ libtest-core.la
+
+libtest_core_guile_la_CFLAGS = \
+ ${libtest_core_la_CPPFLAGS} \
+ ${GUILE_CFLAGS}
+
+libtest_core_guile_la_LDFLAGS = \
+ -rpath ${exec-prefix}/lib
+
+if WITH_PYTHON
+
+noinst_LTLIBRARIES += _test_stuff.la
+
+_test_stuff_la_SOURCES = \
+ swig-test-stuff-python.c
+_test_stuff_la_CFLAGS = \
+ ${libtest_core_la_CPPFLAGS} \
+ ${PYTHON_CPPFLAGS}
+_test_stuff_la_LDFLAGS = \
+ ${PYTHON_LDFLAGS} \
+ -module \
+ -rpath ${exec-prefix}/lib
+
+_test_stuff_la_LIBADD = \
+ ${PYTHON_LIBS} \
+ ${PYTHON_EXTRA_LIBS} \
+ libtest-core.la
+
+endif
+SCM_FILES = test-stuff.scm
+
+gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
+gncmod_DATA = $(SCM_FILES)
+
+.scm-links:
+ $(RM) -rf gnucash
+ mkdir -p gnucash
+if GNUCASH_SEPARATE_BUILDDIR
+ for X in ${SCM_FILES} ; do \
+ $(LN_S) -f ${srcdir}/$$X . ; \
+ done
+endif
+ ( cd gnucash; for A in $(SCM_FILES) ; do $(LN_S) -f ../$$A . ; done )
+if ! OS_WIN32
+# Windows knows no "ln -s" but uses "cp": must copy every time (see bug #566567).
+ touch .scm-links
+endif
+
+clean-local:
+ $(RM) -rf gnucash
+
+noinst_DATA = .scm-links
+CLEANFILES = .scm-links
+
+EXTRA_DIST = \
+ $(SCM_FILES) \
+ swig-test-stuff-python.c \
+ swig-test-stuff-guile.c \
+ test-stuff.i
+
+MAINTAINERCLEANFILES = swig-test-stuff-guile.c swig-test-stuff-python.c
\ No newline at end of file
Added: gnucash/trunk/src/test-core/test-stuff.i
===================================================================
--- gnucash/trunk/src/test-core/test-stuff.i (rev 0)
+++ gnucash/trunk/src/test-core/test-stuff.i 2011-12-12 22:41:41 UTC (rev 21724)
@@ -0,0 +1,89 @@
+%module test_stuff
+%{
+#include "config.h"
+#include "test-stuff.h"
+%}
+
+#if defined(SWIGGUILE)
+%{
+SCM scm_init_test_stuff_module (void);
+%}
+#endif
+
+#if defined(SWIGPYTHON)
+%{
+/* avoid no previous prototype warning/error */
+#if PY_VERSION_HEX >= 0x03000000
+PyObject*
+#else
+void
+#endif
+SWIG_init (void);
+%}
+#endif
+
+%import "base-typemaps.i"
+
+typedef struct
+{
+ GLogLevelFlags log_level;
+ gchar *log_domain;
+ gchar *msg;
+} TestErrorStruct;
+
+typedef enum {
+ /* log flags */
+ G_LOG_FLAG_RECURSION = 1 << 0,
+ G_LOG_FLAG_FATAL = 1 << 1,
+
+ /* GLib log levels */
+ G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
+ G_LOG_LEVEL_CRITICAL = 1 << 3,
+ G_LOG_LEVEL_WARNING = 1 << 4,
+ G_LOG_LEVEL_MESSAGE = 1 << 5,
+ G_LOG_LEVEL_INFO = 1 << 6,
+ G_LOG_LEVEL_DEBUG = 1 << 7,
+
+ G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
+} GLogLevelFlags;
+
+typedef gboolean (*GLogFunc) (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data);
+
+void test_add_error (TestErrorStruct *error);
+void test_clear_error_list (void);
+guint test_set_checked_handler (const char *domain, GLogLevelFlags level,
+ gpointer data);
+guint test_set_list_handler (const char *domain, GLogLevelFlags level,
+ gpointer data);
+guint test_set_null_handler (const char *domain, GLogLevelFlags level,
+ gpointer data);
+
+%{
+
+static guint
+test_set_checked_handler (const char *domain, GLogLevelFlags level,
+ gpointer data)
+{
+ return g_log_set_handler (domain, level,
+ (GLogFunc)test_checked_handler, data);
+}
+static guint
+test_set_list_handler (const char *domain, GLogLevelFlags level,
+ gpointer data)
+{
+ return g_log_set_handler (domain, level,
+ (GLogFunc)test_list_handler, data);
+}
+static guint
+test_set_null_handler (const char *domain, GLogLevelFlags level,
+ gpointer data)
+{
+ return g_log_set_handler (domain, level,
+ (GLogFunc)test_null_handler, data);
+}
+%}
+void g_log_remove_handler (const char *log_domain, guint handler);
+
Added: gnucash/trunk/src/test-core/test-stuff.scm
===================================================================
--- gnucash/trunk/src/test-core/test-stuff.scm (rev 0)
+++ gnucash/trunk/src/test-core/test-stuff.scm 2011-12-12 22:41:41 UTC (rev 21724)
@@ -0,0 +1,27 @@
+(define-module (gnucash test-stuff))
+(load-extension "libtest-core-guile" "scm_init_test_stuff_module")
+(use-modules (test_stuff))
+
+(re-export TestErrorStruct-log-level-set)
+(re-export TestErrorStruct-log-level-get)
+(re-export TestErrorStruct-log-domain-set)
+(re-export TestErrorStruct-log-domain-get)
+(re-export TestErrorStruct-msg-set)
+(re-export TestErrorStruct-msg-get)
+(re-export new-TestErrorStruct)
+(re-export delete-TestErrorStruct)
+(re-export G-LOG-FLAG-RECURSION)
+(re-export G-LOG-FLAG-FATAL)
+(re-export G-LOG-LEVEL-ERROR)
+(re-export G-LOG-LEVEL-CRITICAL)
+(re-export G-LOG-LEVEL-WARNING)
+(re-export G-LOG-LEVEL-MESSAGE)
+(re-export G-LOG-LEVEL-INFO)
+(re-export G-LOG-LEVEL-DEBUG)
+(re-export G-LOG-LEVEL-MASK)
+(re-export test-add-error)
+(re-export test-clear-error-list)
+(re-export g-log-remove-handler)
+(re-export test-set-checked-handler)
+(re-export test-set-null-handler)
+(re-export test-set-list-handler)
More information about the gnucash-changes
mailing list