mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-21 17:37:53 +02:00
gtestutils: Allow failing a test with a printf-style message
This allows a pattern like g_test_message ("cannot reticulate splines: %s", error->message); g_test_fail (); to be replaced by the simpler g_test_fail_printf ("cannot reticulate splines: %s", error->message); with the secondary benefit of making the message available to TAP consumers as part of the "not ok" message. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
@@ -49,6 +49,12 @@ test_fail (void)
|
||||
g_test_fail ();
|
||||
}
|
||||
|
||||
static void
|
||||
test_fail_printf (void)
|
||||
{
|
||||
g_test_fail_printf ("this test intentionally left failing");
|
||||
}
|
||||
|
||||
static void
|
||||
test_incomplete (void)
|
||||
{
|
||||
@@ -123,6 +129,10 @@ main (int argc,
|
||||
{
|
||||
g_test_add_func ("/fail", test_fail);
|
||||
}
|
||||
else if (g_strcmp0 (argv1, "fail-printf") == 0)
|
||||
{
|
||||
g_test_add_func ("/fail-printf", test_fail_printf);
|
||||
}
|
||||
else if (g_strcmp0 (argv1, "all-non-failures") == 0)
|
||||
{
|
||||
g_test_add_func ("/pass", test_pass);
|
||||
|
Reference in New Issue
Block a user