[folks] Override the test log handler for Telepathy tests.



commit fb335d6e40ad765ce9da55909ffe7f7464921423
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Mon Jan 10 21:59:39 2011 -0800

    Override the test log handler for Telepathy tests.
    
    This avoids aborting and printing unnecessary stack traces for the
    well-known Telepathy-logger warning message.
    
    Fixes bgo#639195 - Print stack traces for failed tests to improve
    remote debugging

 NEWS                                      |    2 ++
 tests/lib/telepathy/contactlist/backend.c |   13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index d8c4655..f2d9bc5 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ Bugs fixed:
 * Bug 629083 â?? Review coding conventions in folks
 * Bug 629075 â?? Add folks command line application
 * Bug 638609 â?? libfolks hard-codes backend names for debugging
+* Bug 639195 â?? Print stack traces for failed tests to improve remote
+  debugging
 
 Overview of changes from libfolks 0.3.2 to libfolks 0.3.3
 =========================================================
diff --git a/tests/lib/telepathy/contactlist/backend.c b/tests/lib/telepathy/contactlist/backend.c
index a84fda0..c656cbf 100644
--- a/tests/lib/telepathy/contactlist/backend.c
+++ b/tests/lib/telepathy/contactlist/backend.c
@@ -124,9 +124,17 @@ _log_fatal_handler (const char *domain,
    const char *message,
    gpointer user_data)
 {
-  return !g_str_has_suffix (message,
+  gboolean fatal;
+
+  /* Ignore the error caused by not running the logger */
+  fatal = !g_str_has_suffix (message,
       "The name org.freedesktop.Telepathy.Logger was not provided by any "
       ".service files");
+
+  if (fatal)
+    g_on_error_stack_trace ("libtool --mode=exec gdb");
+
+  return fatal;
 }
 
 void
@@ -138,7 +146,8 @@ tp_test_backend_set_up (TpTestBackend *self)
   gchar *object_path;
   GError *error = NULL;
 
-  /* Ignore the error caused by not running the logger */
+  /* Override the handler set in the general Folks.TestCase class */
+  g_log_set_default_handler (g_log_default_handler, NULL);
   g_test_log_set_fatal_handler (_log_fatal_handler, NULL);
 
   priv->daemon = tp_dbus_daemon_dup (&error);



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