Factor Tp logger warning out of Tp tests.
authorTravis Reitter <travis.reitter@collabora.co.uk>
Tue, 11 Jan 2011 00:50:27 +0000 (16:50 -0800)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Tue, 11 Jan 2011 06:21:16 +0000 (22:21 -0800)
Helps bgo#639195 - Print stack traces for failed tests to improve
remote debugging

tests/lib/telepathy/contactlist/backend.c
tests/telepathy/individual-properties.vala
tests/telepathy/individual-retrieval.vala
tests/telepathy/persona-store-capabilities.vala

index 62311b1..a84fda0 100644 (file)
@@ -118,6 +118,17 @@ tp_test_backend_new (void)
   return g_object_new (TP_TEST_TYPE_BACKEND, NULL);
 }
 
+static gboolean
+_log_fatal_handler (const char *domain,
+   GLogLevelFlags flags,
+   const char *message,
+   gpointer user_data)
+{
+  return !g_str_has_suffix (message,
+      "The name org.freedesktop.Telepathy.Logger was not provided by any "
+      ".service files");
+}
+
 void
 tp_test_backend_set_up (TpTestBackend *self)
 {
@@ -127,6 +138,9 @@ tp_test_backend_set_up (TpTestBackend *self)
   gchar *object_path;
   GError *error = NULL;
 
+  /* Ignore the error caused by not running the logger */
+  g_test_log_set_fatal_handler (_log_fatal_handler, NULL);
+
   priv->daemon = tp_dbus_daemon_dup (&error);
   if (error != NULL)
     g_error ("Couldn't get D-Bus daemon: %s", error->message);
index 578aac8..296e16c 100644 (file)
@@ -38,13 +38,6 @@ public class IndividualPropertiesTests : Folks.TestCase
     {
       var main_loop = new GLib.MainLoop (null, false);
 
-      /* Ignore the error caused by not running the logger */
-      Test.log_set_fatal_handler ((d, l, m) =>
-        {
-          return !m.has_suffix ("The name org.freedesktop.Telepathy.Logger " +
-              "was not provided by any .service files");
-        });
-
       /* Set up the aggregator */
       var aggregator = new IndividualAggregator ();
       aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
@@ -93,13 +86,6 @@ public class IndividualPropertiesTests : Folks.TestCase
       var main_loop = new GLib.MainLoop (null, false);
       var alias_notified = false;
 
-      /* Ignore the error caused by not running the logger */
-      Test.log_set_fatal_handler ((d, l, m) =>
-        {
-          return !m.has_suffix ("The name org.freedesktop.Telepathy.Logger " +
-              "was not provided by any .service files");
-        });
-
       /* Set up the aggregator */
       var aggregator = new IndividualAggregator ();
       aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
@@ -163,13 +149,6 @@ public class IndividualPropertiesTests : Folks.TestCase
       var main_loop = new GLib.MainLoop (null, false);
       var alias_notified = false;
 
-      /* Ignore the error caused by not running the logger */
-      Test.log_set_fatal_handler ((d, l, m) =>
-        {
-          return !m.has_suffix ("The name org.freedesktop.Telepathy.Logger " +
-              "was not provided by any .service files");
-        });
-
       /* Set up the aggregator */
       var aggregator = new IndividualAggregator ();
       aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
index 438019c..8851384 100644 (file)
@@ -48,13 +48,6 @@ public class IndividualRetrievalTests : Folks.TestCase
     {
       var main_loop = new GLib.MainLoop (null, false);
 
-      /* Ignore the error caused by not running the logger */
-      Test.log_set_fatal_handler ((d, l, m) =>
-        {
-          return !m.has_suffix ("The name org.freedesktop.Telepathy.Logger " +
-              "was not provided by any .service files");
-        });
-
       /* work on a copy so we can mangle it */
       HashSet<string> expected_individuals = new HashSet<string> ();
       foreach (var id in this.default_individuals)
@@ -111,13 +104,6 @@ public class IndividualRetrievalTests : Folks.TestCase
     {
       var main_loop = new GLib.MainLoop (null, false);
 
-      /* Ignore the error caused by not running the logger */
-      Test.log_set_fatal_handler ((d, l, m) =>
-        {
-          return !m.has_suffix ("The name org.freedesktop.Telepathy.Logger " +
-              "was not provided by any .service files");
-        });
-
       HashSet<string> added_individuals = new HashSet<string> ();
       added_individuals.add ("master.shake@example.com");
       added_individuals.add ("2wycked@example.com");
index 94060c8..f031f26 100644 (file)
@@ -36,13 +36,6 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
     {
       var main_loop = new GLib.MainLoop (null, false);
 
-      /* Ignore the error caused by not running the logger */
-      Test.log_set_fatal_handler ((d, l, m) =>
-        {
-          return !m.has_suffix ("The name org.freedesktop.Telepathy.Logger " +
-              "was not provided by any .service files");
-        });
-
       var backend_store = BackendStore.dup ();
       backend_store.backend_available.connect ((b) =>
           {