From aef6af8bc8b41b997599f6819ef39c55d423900e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 11 Jul 2018 16:31:38 +0100 Subject: [PATCH 6/7] 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 --- test/test-utils-glib.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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); } -- 2.18.0