[libsoup] Add an "expect_warning" variable to the test framework



commit adcfe2b8285817b6d33008b71ddf69ca8b254b6b
Author: Dan Winship <danw gnome org>
Date:   Sun Apr 19 11:24:43 2009 -0400

    Add an "expect_warning" variable to the test framework
    
    This lets a test tell the log handler that it is expecting to cause a
    warning, so it shouldn't be treated as an error
---
 tests/test-utils.c |   11 +++++++++--
 tests/test-utils.h |    1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/test-utils.c b/tests/test-utils.c
index b970ed4..0b13ca1 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -21,6 +21,7 @@ static void test_server_shutdown (void);
 static SoupLogger *logger;
 
 int debug_level, errors;
+gboolean expect_warning;
 static int http_debug_level;
 
 static gboolean
@@ -66,9 +67,15 @@ static void
 test_log_handler (const char *log_domain, GLogLevelFlags log_level,
 		  const char *message, gpointer user_data)
 {
+	if (log_level & (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL)) {
+		if (expect_warning) {
+			expect_warning = FALSE;
+			debug_printf (2, "Got expected warning: %s\n", message);
+			return;
+		} else
+			errors++;
+	}
 	g_log_default_handler (log_domain, log_level, message, user_data);
-	if (log_level & (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL))
-		errors++;
 }
 
 void
diff --git a/tests/test-utils.h b/tests/test-utils.h
index 803c344..add5366 100644
--- a/tests/test-utils.h
+++ b/tests/test-utils.h
@@ -8,6 +8,7 @@ void test_init    (int argc, char **argv, GOptionEntry *entries);
 void test_cleanup (void);
 
 extern int debug_level, errors;
+extern gboolean expect_warning;
 void debug_printf (int level, const char *format, ...) G_GNUC_PRINTF (2, 3);
 
 #ifdef HAVE_APACHE



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