mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 06:26:15 +01:00
Support TAP as an output format
Initial support for the Test Anything Protocol for GTest output. Use the --tap option to get TAP output. More information about TAP can be found e.g. here: http://en.wikipedia.org/wiki/Test_Anything_Protocol https://bugzilla.gnome.org/show_bug.cgi?id=692125
This commit is contained in:
parent
69582bf635
commit
19aafc4ca4
@ -570,6 +570,7 @@ static char *test_trap_last_stdout = NULL;
|
|||||||
static char *test_trap_last_stderr = NULL;
|
static char *test_trap_last_stderr = NULL;
|
||||||
static char *test_uri_base = NULL;
|
static char *test_uri_base = NULL;
|
||||||
static gboolean test_debug_log = FALSE;
|
static gboolean test_debug_log = FALSE;
|
||||||
|
static gboolean test_tap_log = FALSE;
|
||||||
static DestroyEntry *test_destroy_queue = NULL;
|
static DestroyEntry *test_destroy_queue = NULL;
|
||||||
static char *test_argv0 = NULL;
|
static char *test_argv0 = NULL;
|
||||||
static char *test_argv0_dirname;
|
static char *test_argv0_dirname;
|
||||||
@ -658,7 +659,7 @@ g_test_log (GTestLogType lbit,
|
|||||||
guint n_args,
|
guint n_args,
|
||||||
long double *largs)
|
long double *largs)
|
||||||
{
|
{
|
||||||
gboolean fail = lbit == G_TEST_LOG_STOP_CASE && largs[0] != G_TEST_RUN_SUCCESS;
|
gboolean fail;
|
||||||
GTestLogMsg msg;
|
GTestLogMsg msg;
|
||||||
gchar *astrings[3] = { NULL, NULL, NULL };
|
gchar *astrings[3] = { NULL, NULL, NULL };
|
||||||
guint8 *dbuffer;
|
guint8 *dbuffer;
|
||||||
@ -667,32 +668,67 @@ g_test_log (GTestLogType lbit,
|
|||||||
switch (lbit)
|
switch (lbit)
|
||||||
{
|
{
|
||||||
case G_TEST_LOG_START_BINARY:
|
case G_TEST_LOG_START_BINARY:
|
||||||
if (g_test_verbose())
|
if (test_tap_log)
|
||||||
|
g_print ("# random seed: %s\n", string2);
|
||||||
|
else if (g_test_verbose())
|
||||||
g_print ("GTest: random seed: %s\n", string2);
|
g_print ("GTest: random seed: %s\n", string2);
|
||||||
break;
|
break;
|
||||||
case G_TEST_LOG_START_SUITE:
|
case G_TEST_LOG_START_SUITE:
|
||||||
|
if (test_tap_log)
|
||||||
|
{
|
||||||
|
if (string1[0] != 0)
|
||||||
|
g_print ("# Start of %s tests\n", string1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case G_TEST_LOG_STOP_SUITE:
|
case G_TEST_LOG_STOP_SUITE:
|
||||||
|
if (test_tap_log)
|
||||||
|
{
|
||||||
|
if (string1[0] != 0)
|
||||||
|
g_print ("# End of %s tests\n", string1);
|
||||||
|
else
|
||||||
|
g_print ("1..%d\n", test_run_count);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case G_TEST_LOG_STOP_CASE:
|
case G_TEST_LOG_STOP_CASE:
|
||||||
if (g_test_verbose())
|
fail = largs[0] != G_TEST_RUN_SUCCESS && largs[0] != G_TEST_RUN_SKIPPED;
|
||||||
|
if (test_tap_log)
|
||||||
|
{
|
||||||
|
g_print ("%s %d %s", fail ? "not ok" : "ok", test_run_count, string1);
|
||||||
|
if (largs[0] == G_TEST_RUN_INCOMPLETE)
|
||||||
|
g_print (" # TODO %s\n", string2 ? string2 : "");
|
||||||
|
else if (largs[0] == 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", fail ? "FAIL" : "OK");
|
||||||
else if (!g_test_quiet())
|
else if (!g_test_quiet())
|
||||||
g_print ("%s\n", fail ? "FAIL" : "OK");
|
g_print ("%s\n", fail ? "FAIL" : "OK");
|
||||||
if (fail && test_mode_fatal)
|
if (fail && test_mode_fatal)
|
||||||
abort();
|
{
|
||||||
|
if (test_tap_log)
|
||||||
|
g_print ("Bail out!\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case G_TEST_LOG_MIN_RESULT:
|
case G_TEST_LOG_MIN_RESULT:
|
||||||
if (g_test_verbose())
|
if (test_tap_log)
|
||||||
|
g_print ("# min perf: %s\n", string1);
|
||||||
|
else if (g_test_verbose())
|
||||||
g_print ("(MINPERF:%s)\n", string1);
|
g_print ("(MINPERF:%s)\n", string1);
|
||||||
break;
|
break;
|
||||||
case G_TEST_LOG_MAX_RESULT:
|
case G_TEST_LOG_MAX_RESULT:
|
||||||
if (g_test_verbose())
|
if (test_tap_log)
|
||||||
|
g_print ("# max perf: %s\n", string1);
|
||||||
|
else if (g_test_verbose())
|
||||||
g_print ("(MAXPERF:%s)\n", string1);
|
g_print ("(MAXPERF:%s)\n", string1);
|
||||||
break;
|
break;
|
||||||
case G_TEST_LOG_MESSAGE:
|
case G_TEST_LOG_MESSAGE:
|
||||||
case G_TEST_LOG_ERROR:
|
case G_TEST_LOG_ERROR:
|
||||||
if (g_test_verbose())
|
if (test_tap_log)
|
||||||
|
g_print ("# %s\n", string1);
|
||||||
|
else if (g_test_verbose())
|
||||||
g_print ("(MSG: %s)\n", string1);
|
g_print ("(MSG: %s)\n", string1);
|
||||||
break;
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
@ -712,7 +748,9 @@ g_test_log (GTestLogType lbit,
|
|||||||
switch (lbit)
|
switch (lbit)
|
||||||
{
|
{
|
||||||
case G_TEST_LOG_START_CASE:
|
case G_TEST_LOG_START_CASE:
|
||||||
if (g_test_verbose())
|
if (test_tap_log)
|
||||||
|
;
|
||||||
|
else if (g_test_verbose())
|
||||||
g_print ("GTest: run: %s\n", string1);
|
g_print ("GTest: run: %s\n", string1);
|
||||||
else if (!g_test_quiet())
|
else if (!g_test_quiet())
|
||||||
g_print ("%s: ", string1);
|
g_print ("%s: ", string1);
|
||||||
@ -756,6 +794,11 @@ parse_args (gint *argc_p,
|
|||||||
test_debug_log = TRUE;
|
test_debug_log = TRUE;
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
}
|
}
|
||||||
|
else if (strcmp (argv[i], "--tap") == 0)
|
||||||
|
{
|
||||||
|
test_tap_log = TRUE;
|
||||||
|
argv[i] = NULL;
|
||||||
|
}
|
||||||
else if (strcmp ("--GTestLogFD", argv[i]) == 0 || strncmp ("--GTestLogFD=", argv[i], 13) == 0)
|
else if (strcmp ("--GTestLogFD", argv[i]) == 0 || strncmp ("--GTestLogFD=", argv[i], 13) == 0)
|
||||||
{
|
{
|
||||||
gchar *equal = argv[i] + 12;
|
gchar *equal = argv[i] + 12;
|
||||||
|
Loading…
Reference in New Issue
Block a user