From d7e35101c537a8ec7c86e8e19313e8a20dd72ce3 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 27 Jun 2015 09:52:12 -0700 Subject: [PATCH] add configure option to run tests without valgrind --- Makefile.am | 9 +++++++++ configure.ac | 7 +++++++ tests/setup | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 0d335daa..8598f4c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,14 @@ libjq_la_LDFLAGS = -export-symbols-regex '^j[qv]_' -version-info 1:4:0 include_HEADERS = jv.h jq.h +### Running tests under Valgrind + +if ENABLE_VALGRIND +NO_VALGRIND = +else +NO_VALGRIND = 1 +endif + ### Error injection for testing if ENABLE_ERROR_INJECTION @@ -80,6 +88,7 @@ endif ### Tests (make check) TESTS = tests/mantest tests/jqtest tests/onigtest tests/shtest +TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND) ### Building the manpage diff --git a/configure.ac b/configure.ac index ccbe8dcb..af619fbe 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,12 @@ AC_CHECK_FUNCS(memmem) AC_CHECK_FUNCS(mkstemp) +dnl Running tests with Valgrind is slow. It is faster to iterate on +dnl code without Valgrind until tests pass, then enable Valgrind and +dnl fix leaks. +AC_ARG_ENABLE([valgrind], + AC_HELP_STRING([--disable-valgrind], [do not run tests under Valgrind])) + dnl Don't attempt to build docs if there's no Ruby lying around AC_ARG_ENABLE([docs], AC_HELP_STRING([--disable-docs], [don't build docs])) @@ -119,6 +125,7 @@ EOF fi ]) +AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno]) AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes]) AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes]) diff --git a/tests/setup b/tests/setup index d94ca63a..35a97913 100755 --- a/tests/setup +++ b/tests/setup @@ -8,7 +8,7 @@ JQTESTDIR=$(cd "$(dirname "$0")" && pwd) JQBASEDIR=$JQTESTDIR/.. JQ=$JQBASEDIR/jq -if which valgrind > /dev/null; then +if [ -z "${NO_VALGRIND-}" ] && which valgrind > /dev/null; then VALGRIND="valgrind --error-exitcode=1 --leak-check=full \ --suppressions=$JQTESTDIR/onig.supp" Q=-q