[glib: 2/4] gtestutils: Output in TAP format by default



commit ad175766575b23be920f41cdb1c350447c743347
Author: Philip Withnall <withnall endlessm com>
Date:   Tue May 14 12:04:21 2019 +0100

    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

 glib/gtestutils.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 3eca0a4d3..2ec1398ec 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -236,7 +236,8 @@
  * 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,
  * [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_uri_base = NULL;
 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 DestroyEntry *test_destroy_queue = 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);
             }
           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)
         {
@@ -1136,6 +1140,10 @@ parse_args (gint    *argc_p,
           }
 #endif
           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)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]