Don't g_test_assert_expected_messages for g_error

Don't allow the user to assert for expected g_error().  They need to use
subprocess for this.

https://bugzilla.gnome.org/show_bug.cgi?id=709615
This commit is contained in:
Ryan Lortie 2013-10-18 20:40:57 -04:00
parent 6957004007
commit 8dfb070329
2 changed files with 11 additions and 0 deletions

View File

@ -1159,6 +1159,7 @@ g_test_expect_message (const gchar *log_domain,
g_return_if_fail (log_level != 0);
g_return_if_fail (pattern != NULL);
g_return_if_fail (~log_level & G_LOG_LEVEL_ERROR);
expected = g_new (GTestExpectedMessage, 1);
expected->log_domain = g_strdup (log_domain);

View File

@ -380,6 +380,15 @@ test_expected_messages_null_domain (void)
g_test_assert_expected_messages ();
}
static void
test_expected_messages_expect_error (void)
{
/* make sure we can't try to expect a g_error() */
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*G_LOG_LEVEL_ERROR*");
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "this won't work");
g_test_assert_expected_messages ();
}
static void
test_expected_messages_extra_warning (void)
{
@ -590,6 +599,7 @@ main (int argc,
g_test_add_func ("/misc/expected-messages/subprocess/null-domain", test_expected_messages_null_domain);
g_test_add_func ("/misc/expected-messages/subprocess/extra-warning", test_expected_messages_extra_warning);
g_test_add_func ("/misc/expected-messages/subprocess/unexpected-extra-warning", test_expected_messages_unexpected_extra_warning);
g_test_add_func ("/misc/expected-messages/expect-error", test_expected_messages_expect_error);
g_test_add_func ("/misc/dash-p", test_dash_p);
g_test_add_func ("/misc/dash-p/child", test_dash_p_child);