gtestutils: Output in TAP format by default

Only disable TAP output if the `--GTestLogFD` argument is passed to the
test, which is passed in by the (deprecated) gtester harness, and
shouldn’t ever have been passed in by anything else.

Also disable it when running a subprocess, using `--GTestSubprocess`,
since users commonly strictly check the stdout and stderr of test
subprocesses.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1619
This commit is contained in:
Philip Withnall 2019-05-14 12:04:21 +01:00
parent 662cddcb4b
commit ad17576657

View File

@ -236,7 +236,8 @@
* the [glib.mk](https://gitlab.gnome.org/GNOME/glib/blob/glib-2-58/glib.mk) * the [glib.mk](https://gitlab.gnome.org/GNOME/glib/blob/glib-2-58/glib.mk)
* Automake template provided by GLib. Note, however, that since GLib 2.62, * Automake template provided by GLib. Note, however, that since GLib 2.62,
* [gtester][gtester] and [gtester-report][gtester-report] have been deprecated * [gtester][gtester] and [gtester-report][gtester-report] have been deprecated
* in favour of using TAP. * in favour of using TAP. The `--tap` argument to tests is enabled by default
* as of GLib 2.62.
*/ */
/** /**
@ -833,7 +834,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 gboolean test_tap_log = TRUE; /* default to TAP as of GLib 2.62; see #1619; the non-TAP output mode is deprecated */
static gboolean test_nonfatal_assertions = FALSE; static gboolean test_nonfatal_assertions = FALSE;
static DestroyEntry *test_destroy_queue = NULL; static DestroyEntry *test_destroy_queue = NULL;
static char *test_argv0 = NULL; static char *test_argv0 = NULL;
@ -1109,6 +1110,9 @@ parse_args (gint *argc_p,
test_log_fd = g_ascii_strtoull (argv[i], NULL, 0); test_log_fd = g_ascii_strtoull (argv[i], NULL, 0);
} }
argv[i] = NULL; argv[i] = NULL;
/* Force non-TAP output when using gtester */
test_tap_log = FALSE;
} }
else if (strcmp ("--GTestSkipCount", argv[i]) == 0 || strncmp ("--GTestSkipCount=", argv[i], 17) == 0) else if (strcmp ("--GTestSkipCount", argv[i]) == 0 || strncmp ("--GTestSkipCount=", argv[i], 17) == 0)
{ {
@ -1136,6 +1140,10 @@ parse_args (gint *argc_p,
} }
#endif #endif
argv[i] = NULL; argv[i] = NULL;
/* Force non-TAP output when spawning a subprocess, since people often
* test the stdout/stderr of the subprocess strictly */
test_tap_log = FALSE;
} }
else if (strcmp ("-p", argv[i]) == 0 || strncmp ("-p=", argv[i], 3) == 0) else if (strcmp ("-p", argv[i]) == 0 || strncmp ("-p=", argv[i], 3) == 0)
{ {