From: David Tolnay Date: Sat, 27 Jun 2015 17:16:13 +0000 (-0700) Subject: flag to enable gcov and coveralls X-Git-Tag: jq-1.5rc2~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F834%2Fhead;p=jq flag to enable gcov and coveralls --- diff --git a/.travis.yml b/.travis.yml index 8c477aa..565054c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,15 @@ sudo: false language: c +compiler: + - gcc + - clang + +matrix: + include: + - compiler: gcc + env: COVERAGE="--disable-valgrind --enable-gcov" + addons: apt: packages: @@ -23,13 +32,14 @@ install: - ar p libonig2_5.9.6-1_amd64.deb data.tar.xz | tar xJ - mv usr/lib/x86_64-linux-gnu/libonig.so* usr/lib - - valgrind --version + - if [ -n "$COVERAGE" ]; then pip install --user cpp-coveralls; fi before_script: - autoreconf -i - ./configure --with-oniguruma=usr YACC="usr/bin/bison -y" + $COVERAGE script: - make -j4 @@ -37,13 +47,13 @@ script: BISON_PKGDATADIR=$(pwd)/usr/share/bison - make check -j4 +after_script: + - rm -rf .libs # don't care about coverage for libjq + - if [ -n "$COVERAGE" ]; then coveralls --gcov-options '\-lp'; fi + after_failure: - cat test-suite.log - cat tests/*.log -compiler: - - gcc - - clang - notifications: email: false diff --git a/Makefile.am b/Makefile.am index 8598f4c..15d1b29 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,6 +55,12 @@ else NO_VALGRIND = 1 endif +### Code coverage with gcov + +if ENABLE_GCOV +AM_CFLAGS += --coverage --no-inline +endif + ### Error injection for testing if ENABLE_ERROR_INJECTION @@ -176,11 +182,15 @@ dist-clean-local: # Not sure why this doesn't get cleaned up automatically, guess # automake used to man pages which are hand coded? # 'make clean' doesn't delete the manpage if it can't be rebuilt -.PHONY: clean-local-docs clean-local-docs: if ENABLE_DOCS rm -f jq.1 endif -clean-local: clean-local-docs +clean-local-gcov: + rm -f *.gcno *.gcda *.gcov + +clean-local: clean-local-docs clean-local-gcov rm -f version.h .remake-version-h + +.PHONY: clean-local-docs clean-local-gcov diff --git a/configure.ac b/configure.ac index af619fb..1654429 100644 --- a/configure.ac +++ b/configure.ac @@ -89,6 +89,10 @@ dnl fix leaks. AC_ARG_ENABLE([valgrind], AC_HELP_STRING([--disable-valgrind], [do not run tests under Valgrind])) +dnl Code coverage +AC_ARG_ENABLE([gcov], + AC_HELP_STRING([--enable-gcov], [enable gcov code coverage tool])) + 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])) @@ -126,6 +130,7 @@ EOF ]) AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno]) +AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes]) 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])