mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
gtestutils: Improve TAP reporting on tests failures
When we've a failure our TAP reporting just bails out without that is clear what is the test that has failed. So in this case, expose a "not ok" message if the test name is known, and use it to report the error message too if available. Otherwise just use the same Bail out! strategy.
This commit is contained in:
parent
d8e4c1a8f8
commit
a707cebcd9
@ -1219,7 +1219,26 @@ g_test_log (GTestLogType lbit,
|
|||||||
while ((line = strchr (line, '\n')))
|
while ((line = strchr (line, '\n')))
|
||||||
*(line++) = ' ';
|
*(line++) = ' ';
|
||||||
|
|
||||||
|
if (message)
|
||||||
|
message = g_strstrip (message);
|
||||||
|
|
||||||
|
if (test_run_name && *test_run_name != '\0')
|
||||||
|
{
|
||||||
|
if (message && *message != '\0')
|
||||||
|
g_test_tap_print (subtest_level, FALSE, "not ok %s - %s\n",
|
||||||
|
test_run_name, message);
|
||||||
|
else
|
||||||
|
g_test_tap_print (subtest_level, FALSE, "not ok %s\n",
|
||||||
|
test_run_name);
|
||||||
|
|
||||||
|
g_clear_pointer (&message, g_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message && *message != '\0')
|
||||||
g_test_tap_print (subtest_level, FALSE, "Bail out! %s\n", message);
|
g_test_tap_print (subtest_level, FALSE, "Bail out! %s\n", message);
|
||||||
|
else
|
||||||
|
g_test_tap_print (subtest_level, FALSE, "Bail out!\n");
|
||||||
|
|
||||||
g_free (message);
|
g_free (message);
|
||||||
}
|
}
|
||||||
else if (g_test_verbose ())
|
else if (g_test_verbose ())
|
||||||
|
@ -2676,8 +2676,9 @@ test_tap_error (void)
|
|||||||
g_assert_nonnull (interesting_lines);
|
g_assert_nonnull (interesting_lines);
|
||||||
interesting_lines += strlen (expected_tap_header);
|
interesting_lines += strlen (expected_tap_header);
|
||||||
|
|
||||||
g_assert_cmpstr (interesting_lines, ==, "Bail out! GLib-FATAL-ERROR: This should error out "
|
g_assert_cmpstr (interesting_lines, ==, "not ok /error - GLib-FATAL-ERROR: This should error out "
|
||||||
"Because it's just wrong!\n");
|
"Because it's just wrong!\n"
|
||||||
|
"Bail out!\n");
|
||||||
|
|
||||||
g_free (output);
|
g_free (output);
|
||||||
g_strfreev (envp);
|
g_strfreev (envp);
|
||||||
@ -2721,8 +2722,9 @@ test_tap_subtest_error (void)
|
|||||||
interesting_lines += strlen (expected_tap_header);
|
interesting_lines += strlen (expected_tap_header);
|
||||||
|
|
||||||
g_assert_cmpstr (interesting_lines, ==,
|
g_assert_cmpstr (interesting_lines, ==,
|
||||||
TAP_SUBTEST_PREFIX "Bail out! GLib-FATAL-ERROR: This should error out "
|
TAP_SUBTEST_PREFIX "not ok /error - GLib-FATAL-ERROR: This should error out "
|
||||||
"Because it's just wrong!\n");
|
"Because it's just wrong!\n"
|
||||||
|
TAP_SUBTEST_PREFIX "Bail out!\n");
|
||||||
|
|
||||||
g_free (output);
|
g_free (output);
|
||||||
g_ptr_array_unref (argv);
|
g_ptr_array_unref (argv);
|
||||||
@ -2768,8 +2770,9 @@ test_tap_error_and_pass (void)
|
|||||||
g_assert_nonnull (interesting_lines);
|
g_assert_nonnull (interesting_lines);
|
||||||
interesting_lines += strlen (expected_tap_header);
|
interesting_lines += strlen (expected_tap_header);
|
||||||
|
|
||||||
g_assert_cmpstr (interesting_lines, ==, "Bail out! GLib-FATAL-ERROR: This should error out "
|
g_assert_cmpstr (interesting_lines, ==, "not ok /error - GLib-FATAL-ERROR: This should error out "
|
||||||
"Because it's just wrong!\n");
|
"Because it's just wrong!\n"
|
||||||
|
"Bail out!\n");
|
||||||
|
|
||||||
g_free (output);
|
g_free (output);
|
||||||
g_strfreev (envp);
|
g_strfreev (envp);
|
||||||
@ -2813,8 +2816,9 @@ test_tap_subtest_error_and_pass (void)
|
|||||||
interesting_lines += strlen (expected_tap_header);
|
interesting_lines += strlen (expected_tap_header);
|
||||||
|
|
||||||
g_assert_cmpstr (interesting_lines, ==,
|
g_assert_cmpstr (interesting_lines, ==,
|
||||||
TAP_SUBTEST_PREFIX "Bail out! GLib-FATAL-ERROR: This should error out "
|
TAP_SUBTEST_PREFIX "not ok /error - GLib-FATAL-ERROR: This should error out "
|
||||||
"Because it's just wrong!\n");
|
"Because it's just wrong!\n"
|
||||||
|
TAP_SUBTEST_PREFIX "Bail out!\n");
|
||||||
|
|
||||||
g_free (output);
|
g_free (output);
|
||||||
g_ptr_array_unref (argv);
|
g_ptr_array_unref (argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user