]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: Interpret empty command-line arguments as --tap
authorSimon McVittie <smcv@collabora.com>
Wed, 11 Jul 2018 15:31:38 +0000 (16:31 +0100)
committerSimon McVittie <smcv@collabora.com>
Thu, 2 Aug 2018 16:14:21 +0000 (17:14 +0100)
AX_VALGRIND_CHECK overrides LOG_COMPILER, which means we can't rely
on running under glib-tap-test.sh. Default to TAP mode by modifying
our (effective) argv instead.

If you really want the default behaviour (unstructured output) this
can still be achieved by adding some arguments that are a no-op,
such as `-m quick`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194

test/test-utils-glib.c

index 94e28c8981a27c409d625dadf0092c2fe4dd10b2..0fc9fd4ec9c293ea7c19782311a54ae8c179f702 100644 (file)
@@ -603,7 +603,30 @@ set_timeout (guint factor)
 void
 test_init (int *argcp, char ***argvp)
 {
+  /* If our argv only contained the executable name, assume we were
+   * run by Automake with LOG_COMPILER overridden by
+   * VALGRIND_CHECK_RULES from AX_VALGRIND_CHECK, and automatically switch
+   * on TAP output. This avoids needing glib-tap-test.sh. We still use
+   * glib-tap-test.sh in the common case because it replaces \r\n line
+   * endings with \n, which we need if running the tests under Wine. */
+  static char tap[] = "--tap";
+  static char *substitute_argv[] = { NULL, tap, NULL };
+
+  g_return_if_fail (argcp != NULL);
+  g_return_if_fail (*argcp > 0);
+  g_return_if_fail (argvp != NULL);
+  g_return_if_fail (argvp[0] != NULL);
+  g_return_if_fail (argvp[0][0] != NULL);
+
+  if (*argcp == 1)
+    {
+      substitute_argv[0] = (*argvp)[0];
+      *argcp = 2;
+      *argvp = substitute_argv;
+    }
+
   g_test_init (argcp, argvp, NULL);
+
   g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
   set_timeout (1);
 }