mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
Split g_test_log() messages that contain multiple lines
When using TAP we want every single line to be one of the following: - a valid TAP clause - a comment - a blank line Typical explicit test logs are single line comments, but in some cases we might end up printing debug messages from libraries, and those may contain multiple lines. When that happens, we break the TAP and fail the test in conditions entirely outside of our control. One option to avoid outright failure is to always prepend each line of a messge with `#`, to ensure that the whole thing is considered a comment.
This commit is contained in:
parent
d42bb394ac
commit
85eec6aae8
@ -1072,7 +1072,20 @@ g_test_log (GTestLogType lbit,
|
||||
break;
|
||||
case G_TEST_LOG_MESSAGE:
|
||||
if (test_tap_log)
|
||||
g_print ("# %s\n", string1);
|
||||
{
|
||||
if (strstr (string1, "\n") == NULL)
|
||||
g_print ("# %s\n", string1);
|
||||
else
|
||||
{
|
||||
char **lines = g_strsplit (string1, "\n", -1);
|
||||
gsize i;
|
||||
|
||||
for (i = 0; lines[i] != NULL; i++)
|
||||
g_print ("# %s\n", lines[i]);
|
||||
|
||||
g_strfreev (lines);
|
||||
}
|
||||
}
|
||||
else if (g_test_verbose ())
|
||||
g_print ("(MSG: %s)\n", string1);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user