mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-31 21:03:10 +02:00
gtestutils: improve non-TAP output, fix handling of incomplete tests
In non-TAP mode, tests that used g_test_skip() were labelled "OK", and tests that used g_test_incomplete() were labelled "FAIL". Explicitly show them as "SKIP" and "TODO" instead, like in the TAP case. Also, incomplete/TODO tests are not supposed to be treated as failures, so fix that too. https://bugzilla.gnome.org/show_bug.cgi?id=754286
This commit is contained in:
parent
6e382208f7
commit
123ea70d74
@ -645,6 +645,12 @@ typedef enum {
|
||||
G_TEST_RUN_FAILURE,
|
||||
G_TEST_RUN_INCOMPLETE
|
||||
} GTestResult;
|
||||
static const char * const g_test_result_names[] = {
|
||||
"OK",
|
||||
"SKIP",
|
||||
"FAIL",
|
||||
"TODO"
|
||||
};
|
||||
|
||||
/* --- variables --- */
|
||||
static int test_log_fd = -1;
|
||||
@ -765,6 +771,7 @@ g_test_log (GTestLogType lbit,
|
||||
guint n_args,
|
||||
long double *largs)
|
||||
{
|
||||
GTestResult result;
|
||||
gboolean fail;
|
||||
GTestLogMsg msg;
|
||||
gchar *astrings[3] = { NULL, NULL, NULL };
|
||||
@ -796,28 +803,29 @@ g_test_log (GTestLogType lbit,
|
||||
}
|
||||
break;
|
||||
case G_TEST_LOG_STOP_CASE:
|
||||
fail = largs[0] != G_TEST_RUN_SUCCESS && largs[0] != G_TEST_RUN_SKIPPED;
|
||||
result = largs[0];
|
||||
fail = result == G_TEST_RUN_FAILURE;
|
||||
if (test_tap_log)
|
||||
{
|
||||
g_print ("%s %d %s", fail ? "not ok" : "ok", test_run_count, string1);
|
||||
if (largs[0] == G_TEST_RUN_INCOMPLETE)
|
||||
if (result == G_TEST_RUN_INCOMPLETE)
|
||||
g_print (" # TODO %s\n", string2 ? string2 : "");
|
||||
else if (largs[0] == G_TEST_RUN_SKIPPED)
|
||||
else if (result == G_TEST_RUN_SKIPPED)
|
||||
g_print (" # SKIP %s\n", string2 ? string2 : "");
|
||||
else
|
||||
g_print ("\n");
|
||||
}
|
||||
else if (g_test_verbose())
|
||||
g_print ("GTest: result: %s\n", fail ? "FAIL" : "OK");
|
||||
g_print ("GTest: result: %s\n", g_test_result_names[result]);
|
||||
else if (!g_test_quiet())
|
||||
g_print ("%s\n", fail ? "FAIL" : "OK");
|
||||
g_print ("%s\n", g_test_result_names[result]);
|
||||
if (fail && test_mode_fatal)
|
||||
{
|
||||
if (test_tap_log)
|
||||
g_print ("Bail out!\n");
|
||||
abort();
|
||||
}
|
||||
if (largs[0] == G_TEST_RUN_SKIPPED)
|
||||
if (result == G_TEST_RUN_SKIPPED)
|
||||
test_skipped_count++;
|
||||
break;
|
||||
case G_TEST_LOG_MIN_RESULT:
|
||||
|
Loading…
x
Reference in New Issue
Block a user