summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-11-15 22:26:54 -0500
committerDan Winship <danw@gnome.org>2012-12-05 11:15:19 -0500
commite97a2f4195fb5bd8d7777651232dc10487a1ed92 (patch)
treef9adc87df31c162cae422fbe183a44ede8f9d2b2
parentac025007cc571cd767fac8cbd6f937d01773ce28 (diff)
downloadglib-e97a2f4195fb5bd8d7777651232dc10487a1ed92.tar.gz
win32: suppress fatal error dialog box when running tests
When running a test program (ie, if g_test_init() has been called), don't pop up a dialog box when a fatal error occurs. Just print the message to stderr and exit. https://bugzilla.gnome.org/show_bug.cgi?id=679683
-rw-r--r--docs/reference/glib/glib-sections.txt1
-rw-r--r--glib/gmessages.c14
-rw-r--r--glib/gtestutils.c10
-rw-r--r--glib/gtestutils.h1
4 files changed, 21 insertions, 5 deletions
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 546bc98d3..e4e9df41e 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2877,6 +2877,7 @@ g_compute_hmac_for_string
g_test_minimized_result
g_test_maximized_result
g_test_init
+g_test_initialized
g_test_quick
g_test_slow
g_test_thorough
diff --git a/glib/gmessages.c b/glib/gmessages.c
index e2be9ab2c..91d7a21f1 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -820,7 +820,8 @@ mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
strcat (level_prefix, " **");
#ifdef G_OS_WIN32
- win32_keep_fatal_message = (log_level & G_LOG_FLAG_FATAL) != 0;
+ if ((log_level & G_LOG_FLAG_FATAL) != 0 && !g_test_initialized ())
+ win32_keep_fatal_message = TRUE;
#endif
return to_stdout ? 1 : 2;
}
@@ -954,10 +955,13 @@ g_logv (const gchar *log_domain,
if ((test_level & G_LOG_FLAG_FATAL) && !masquerade_fatal)
{
#ifdef G_OS_WIN32
- gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
-
- MessageBox (NULL, locale_msg, NULL,
- MB_ICONERROR|MB_SETFOREGROUND);
+ if (win32_keep_fatal_message)
+ {
+ gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
+
+ MessageBox (NULL, locale_msg, NULL,
+ MB_ICONERROR|MB_SETFOREGROUND);
+ }
if (IsDebuggerPresent () && !(test_level & G_LOG_FLAG_RECURSION))
G_BREAKPOINT ();
else
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 5fba96f4a..c7b724962 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -106,6 +106,16 @@
*/
/**
+ * g_test_initialized:
+ *
+ * Returns %TRUE if g_test_init() has been called.
+ *
+ * Returns: %TRUE if g_test_init() has been called.
+ *
+ * Since: 2.36
+ */
+
+/**
* g_test_quick:
*
* Returns %TRUE if tests are run in quick mode.
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 967fa63b0..372151922 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -92,6 +92,7 @@ void g_test_init (int *argc,
char ***argv,
...);
/* query testing framework config */
+#define g_test_initialized() (g_test_config_vars->test_initialized)
#define g_test_quick() (g_test_config_vars->test_quick)
#define g_test_slow() (!g_test_config_vars->test_quick)
#define g_test_thorough() (!g_test_config_vars->test_quick)