[libgdata] tests: Remove debug log storage system



commit c55465b20f4f3560198894a61b0613b1b72cf4de
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Sun Aug 24 16:47:51 2014 +0100

    tests: Remove debug log storage system
    
    automake's parallel-tests feature now automatically separates and stores
    logs, and only prints them out on test failure. This is exactly what the
    logging code in the tests was doing before, so the logging code can now
    be simplified.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703192

 gdata/tests/common.c |   78 +++++++++++++++----------------------------------
 gdata/tests/common.h |    3 --
 2 files changed, 24 insertions(+), 57 deletions(-)
---
diff --git a/gdata/tests/common.c b/gdata/tests/common.c
index a519476..b5d2fc7 100644
--- a/gdata/tests/common.c
+++ b/gdata/tests/common.c
@@ -32,12 +32,6 @@ static gboolean no_interactive = FALSE;
 /* declaration of debug handler */
 static void gdata_test_debug_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar 
*message, gpointer user_data);
 
-/* declaration of printerr handler */
-static void gdata_test_assert_handler (const gchar *message);
-
-/* global list of debugging messages */
-static GSList *message_list = NULL;
-
 /* Directory to output network trace files to, if trace output is enabled. (NULL otherwise.) */
 static GFile *trace_dir = NULL;
 
@@ -117,10 +111,7 @@ gdata_test_init (int argc, char **argv)
        g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=";);
 
        /* Set handler of debug information */
-       g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, (GLogFunc) gdata_test_debug_handler, 
message_list);
-
-       /* Set handler for printerr */
-       g_set_printerr_handler ((GPrintFunc) gdata_test_assert_handler);
+       g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, (GLogFunc) gdata_test_debug_handler, NULL);
 
        /* Enable full debugging. These options are seriously unsafe, but we don't care for test cases. */
        g_setenv ("LIBGDATA_DEBUG", "4" /* GDATA_LOG_FULL_UNREDACTED */, FALSE);
@@ -873,49 +864,35 @@ gdata_tear_down_async_test_data (GDataAsyncTestData *async_data, gconstpointer t
        g_main_loop_unref (async_data->main_loop);
 }
 
-void
-gdata_test_debug_output (void)
-{
-       if (message_list == NULL) {
-               /* No debugging messages */
-               return;
+static void
+output_log_message (const gchar *message)
+{
+       if (strlen (message) > 2 && message[2] == '<') {
+               /* As debug string starts with direction indicator and space, t.i. "< ", */
+               /* we need access string starting from third character and see if it's   */
+               /* looks like xml - t.i. it starts with '<' */
+               xmlChar *xml_buff;
+               int buffer_size;
+               xmlDocPtr xml_doc;
+               /* we need to cut to the begining of XML string */
+               message = message + 2;
+               /* create xml document and dump it to string buffer */
+               xml_doc = xmlParseDoc ((const xmlChar*) message);
+               xmlDocDumpFormatMemory (xml_doc, &xml_buff, &buffer_size, 1);
+               /* print out structured xml - if it's not xml, it will get error in output */
+               printf("%s", (gchar*) xml_buff);
+               /* free xml structs */
+               xmlFree (xml_buff);
+               xmlFreeDoc (xml_doc);
+       } else {
+               printf ("%s\n", (gchar*) message);
        }
-       do {
-               gchar *message = (gchar*) message_list->data;
-               if (message != NULL) {
-                       if (strlen (message) > 2 && message[2] == '<') {
-                               /* As debug string starts with direction indicator and space, t.i. "< ", */
-                               /* we need access string starting from third character and see if it's   */
-                               /* looks like xml - t.i. it starts with '<' */
-                               xmlChar *xml_buff;
-                               int buffer_size;
-                               xmlDocPtr xml_doc;
-                               /* we need to cut to the begining of XML string */
-                               message = message + 2;
-                               /* create xml document and dump it to string buffer */
-                               xml_doc = xmlParseDoc ((const xmlChar*) message);
-                               xmlDocDumpFormatMemory (xml_doc, &xml_buff, &buffer_size, 1);
-                               /* print out structured xml - if it's not xml, it will get error in output */
-                               printf("%s", (gchar*) xml_buff);
-                               /* free xml structs */
-                               xmlFree (xml_buff);
-                               xmlFreeDoc (xml_doc);
-                       } else {
-                               printf ("%s\n", (gchar*) message);
-                       }
-                       /* free gchar */
-                       g_free ((gpointer) message_list->data);
-               }
-               /* free GSList node */
-               message_list = g_slist_delete_link (message_list, message_list);
-       } while (message_list != NULL);
 }
 
 static void
 gdata_test_debug_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer 
user_data)
 {
-       /* storing debugging messages in GSList for displaying them in case of error */
-       message_list = g_slist_append (message_list, g_strdup (message));
+       output_log_message (message);
 
        /* Log to the trace file. */
        if (message != NULL && (*message == '<' || *message == '>' || *message == ' ') && *(message + 1) == ' 
') {
@@ -923,13 +900,6 @@ gdata_test_debug_handler (const gchar *log_domain, GLogLevelFlags log_level, con
        }
 }
 
-static void
-gdata_test_assert_handler (const gchar *message)
-{
-       gdata_test_debug_output ();
-       printf ("%s", (gchar*) message);
-}
-
 /**
  * gdata_test_set_https_port:
  * @server: a #UhmServer
diff --git a/gdata/tests/common.h b/gdata/tests/common.h
index 38f274c..06319b3 100644
--- a/gdata/tests/common.h
+++ b/gdata/tests/common.h
@@ -308,9 +308,6 @@ gboolean gdata_async_test_cancellation_cb (GDataAsyncTestData *async_data);
 void gdata_set_up_async_test_data (GDataAsyncTestData *async_data, gconstpointer test_data);
 void gdata_tear_down_async_test_data (GDataAsyncTestData *async_data, gconstpointer test_data);
 
-/* Debugging output in case of assert failure */
-void gdata_test_debug_output (void);
-
 /**
  * GDataTestRequestErrorData:
  * @status_code: HTTP response status code


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