mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 03:02:10 +01:00
test: g_debug messages shouldn't affect g_assert_expected_messages
Debug messages are meant to give insight into how a process is proceeding, and are unpredictable in nature. They also often have line numbers in them. This patch ignores debug messages in g_test_assert_expected_messages(). https://bugzilla.gnome.org/show_bug.cgi?id=710991
This commit is contained in:
parent
0d89d38cac
commit
44f13124c9
@ -922,19 +922,19 @@ g_logv (const gchar *log_domain,
|
|||||||
{
|
{
|
||||||
GTestExpectedMessage *expected = expected_messages->data;
|
GTestExpectedMessage *expected = expected_messages->data;
|
||||||
|
|
||||||
expected_messages = g_slist_delete_link (expected_messages,
|
|
||||||
expected_messages);
|
|
||||||
if (g_strcmp0 (expected->log_domain, log_domain) == 0 &&
|
if (g_strcmp0 (expected->log_domain, log_domain) == 0 &&
|
||||||
((log_level & expected->log_level) == expected->log_level) &&
|
((log_level & expected->log_level) == expected->log_level) &&
|
||||||
g_pattern_match_simple (expected->pattern, msg))
|
g_pattern_match_simple (expected->pattern, msg))
|
||||||
{
|
{
|
||||||
|
expected_messages = g_slist_delete_link (expected_messages,
|
||||||
|
expected_messages);
|
||||||
g_free (expected->log_domain);
|
g_free (expected->log_domain);
|
||||||
g_free (expected->pattern);
|
g_free (expected->pattern);
|
||||||
g_free (expected);
|
g_free (expected);
|
||||||
g_free (msg_alloc);
|
g_free (msg_alloc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else if ((log_level & G_LOG_LEVEL_DEBUG) != G_LOG_LEVEL_DEBUG)
|
||||||
{
|
{
|
||||||
gchar level_prefix[STRING_BUFFER_SIZE];
|
gchar level_prefix[STRING_BUFFER_SIZE];
|
||||||
gchar *expected_message;
|
gchar *expected_message;
|
||||||
@ -1148,6 +1148,9 @@ g_assert_warning (const char *log_domain,
|
|||||||
* g_error() intentionally never returns even if the program doesn't
|
* g_error() intentionally never returns even if the program doesn't
|
||||||
* abort; use g_test_trap_subprocess() in this case.
|
* abort; use g_test_trap_subprocess() in this case.
|
||||||
*
|
*
|
||||||
|
* If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
|
||||||
|
* expected via g_test_expect_message() then they will be ignored.
|
||||||
|
*
|
||||||
* Since: 2.34
|
* Since: 2.34
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -1197,6 +1200,9 @@ g_test_assert_expected_messages_internal (const char *domain,
|
|||||||
* Asserts that all messages previously indicated via
|
* Asserts that all messages previously indicated via
|
||||||
* g_test_expect_message() have been seen and suppressed.
|
* g_test_expect_message() have been seen and suppressed.
|
||||||
*
|
*
|
||||||
|
* If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
|
||||||
|
* expected via g_test_expect_message() then they will be ignored.
|
||||||
|
*
|
||||||
* Since: 2.34
|
* Since: 2.34
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -456,6 +456,19 @@ test_expected_messages (void)
|
|||||||
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*nope*");
|
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*nope*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_expected_messages_debug (void)
|
||||||
|
{
|
||||||
|
g_test_expect_message ("Test", G_LOG_LEVEL_WARNING, "warning message");
|
||||||
|
g_log ("Test", G_LOG_LEVEL_DEBUG, "should be ignored");
|
||||||
|
g_log ("Test", G_LOG_LEVEL_WARNING, "warning message");
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
|
g_test_expect_message ("Test", G_LOG_LEVEL_DEBUG, "debug message");
|
||||||
|
g_log ("Test", G_LOG_LEVEL_DEBUG, "debug message");
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_dash_p_hidden (void)
|
test_dash_p_hidden (void)
|
||||||
{
|
{
|
||||||
@ -600,6 +613,7 @@ main (int argc,
|
|||||||
g_test_add_func ("/misc/expected-messages/subprocess/extra-warning", test_expected_messages_extra_warning);
|
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/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/expected-messages/expect-error", test_expected_messages_expect_error);
|
||||||
|
g_test_add_func ("/misc/expected-messages/skip-debug", test_expected_messages_debug);
|
||||||
|
|
||||||
g_test_add_func ("/misc/dash-p", test_dash_p);
|
g_test_add_func ("/misc/dash-p", test_dash_p);
|
||||||
g_test_add_func ("/misc/dash-p/child", test_dash_p_child);
|
g_test_add_func ("/misc/dash-p/child", test_dash_p_child);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user