summaryrefslogtreecommitdiff
path: root/test/test-utils-glib.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2018-07-11 16:31:38 +0100
committerSimon McVittie <smcv@collabora.com>2018-08-02 17:14:21 +0100
commit769c367f734cf9674eb2b153740105979f714548 (patch)
tree95df682b3510cee56a09e40f1c2b9a91db29b301 /test/test-utils-glib.c
parent1c36fc0aa59a580dedf27c24e7df282ca3276450 (diff)
downloaddbus-769c367f734cf9674eb2b153740105979f714548.tar.gz
tests: Interpret empty command-line arguments as --tap
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
Diffstat (limited to 'test/test-utils-glib.c')
-rw-r--r--test/test-utils-glib.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c
index 94e28c89..0fc9fd4e 100644
--- a/test/test-utils-glib.c
+++ b/test/test-utils-glib.c
@@ -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);
}