[libsoup/wip/tap] tests: Use TAP format for all output




commit 3da8080f8ae2f1413a0f73dad8a9da3614991512
Author: Patrick Griffis <pgriffis igalia com>
Date:   Fri Dec 18 13:20:44 2020 -0600

    tests: Use TAP format for all output

 tests/forms-test.c  | 4 ++--
 tests/meson.build   | 8 +++++++-
 tests/server-test.c | 4 ++--
 tests/test-utils.c  | 7 +++++++
 4 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/tests/forms-test.c b/tests/forms-test.c
index 1c9af9ea..8dbdbe54 100644
--- a/tests/forms-test.c
+++ b/tests/forms-test.c
@@ -43,7 +43,7 @@ do_hello_test_curl (int n, gboolean extra, const char *uri)
        char *str_stdout = NULL;
        GError *error = NULL;
 
-       debug_printf (1, "%2d. '%s' '%s'%s: ", n * 2 + (extra ? 2 : 1),
+       debug_printf (1, "%2d. '%s' '%s'%s: \n", n * 2 + (extra ? 2 : 1),
                      tests[n].title ? tests[n].title : "(null)",
                      tests[n].name  ? tests[n].name  : "(null)",
                      extra ? " + extra" : "");
@@ -110,7 +110,7 @@ do_hello_test_libsoup (int n, gboolean extra, const char *uri)
        GBytes *body;
         char *encoded;
 
-       debug_printf (1, "%2d. '%s' '%s'%s: ", n * 2 + (extra ? 2 : 1),
+       debug_printf (1, "%2d. '%s' '%s'%s: \n", n * 2 + (extra ? 2 : 1),
                      tests[n].title ? tests[n].title : "(null)",
                      tests[n].name  ? tests[n].name  : "(null)",
                      extra ? " + extra" : "");
diff --git a/tests/meson.build b/tests/meson.build
index ecb41887..1cae853d 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -159,7 +159,13 @@ foreach test: tests
   )
   # Increase the timeout as on some architectures the tests could be slower
   # than the default 30 seconds.
-  test(test_name, test_target, env : env, is_parallel : test[1], timeout : 60)
+  test(test_name, test_target,
+    args : ['--debug'],
+    env : env,
+    is_parallel : test[1],
+    timeout : 60,
+    protocol : 'tap',
+  )
 endforeach
 
 executable('ntlm-test-helper', 'ntlm-test-helper.c',
diff --git a/tests/server-test.c b/tests/server-test.c
index 9f3f019d..1ae6c385 100644
--- a/tests/server-test.c
+++ b/tests/server-test.c
@@ -1207,7 +1207,7 @@ tunnel_wrote_cb (GObject      *object,
                        g_error_free (error);
                        return;
                } else if (error) {
-                       g_print ("Tunnel write failed: %s\n", error->message);
+                       debug_printf (1, "Tunnel write failed: %s\n", error->message);
                        g_error_free (error);
                }
                tunnel_close (tunnel);
@@ -1253,7 +1253,7 @@ tunnel_read_cb (GObject      *object,
                        g_error_free (error);
                        return;
                } else if (error) {
-                       g_print ("Tunnel read failed: %s\n", error->message);
+                       debug_printf (1, "Tunnel read failed: %s\n", error->message);
                        g_error_free (error);
                }
                tunnel_close (tunnel);
diff --git a/tests/test-utils.c b/tests/test-utils.c
index 27734d8b..9308972f 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -123,10 +123,17 @@ void
 debug_printf (int level, const char *format, ...)
 {
        va_list args;
+        static char last_char = '\n';
 
        if (debug_level < level)
                return;
 
+        /* Very hacky solution to outputing in the TAP format,
+         * every line starts with # */
+        if (last_char == '\n')
+                g_printf ("# ");
+        last_char = format[strlen (format) - 1];
+
        va_start (args, format);
        g_vprintf (format, args);
        va_end (args);


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