gtestutils: Define a custom g_print handler for TAP

When using TAP output in gtest, all the printed strings should be commented
not to break the spec, so enforce this at GTest level, by ensuring that
all the lines written via g_print() will be in the commented form and will
respect the subtest indentation.

As per this we can remove some custom code in g_test_log() as now there are
very few cases in which we need to use the default print handler which is
now private when testing.
This commit is contained in:
Marco Trevisan (Treviño)
2023-01-14 01:47:07 +01:00
parent 3d1736c828
commit 8b7b5f5457
4 changed files with 250 additions and 61 deletions

View File

@@ -93,6 +93,16 @@ test_message (void)
g_test_message ("\nTests that multi\nline\nmessage\nworks with leading and trailing too\n");
}
static void
test_print (void)
{
g_print ("Tests that single line message works\n");
g_print ("test that multiple\nlines ");
g_print ("can be ");
g_print ("written ");
g_print ("separately\n");
}
int
main (int argc,
char *argv[])
@@ -212,6 +222,10 @@ main (int argc,
{
g_test_add_func ("/message", test_message);
}
else if (g_strcmp0 (argv1, "print") == 0)
{
g_test_add_func ("/print", test_print);
}
else
{
g_assert_not_reached ();