]> granicus.if.org Git - jq/commitdiff
flag to enable gcov and coveralls 834/head
authorDavid Tolnay <dtolnay@gmail.com>
Sat, 27 Jun 2015 17:16:13 +0000 (10:16 -0700)
committerDavid Tolnay <dtolnay@gmail.com>
Sat, 27 Jun 2015 18:25:01 +0000 (11:25 -0700)
.travis.yml
Makefile.am
configure.ac

index 8c477aa7ef1c72f5f899be2ba73d4128ce8729c6..565054cb72e5578ae8fa6725c795d4796c02cafa 100644 (file)
@@ -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
index 8598f4c8a110eb32cc365ed8a04701c7c048edce..15d1b29868cf5398ad1ffc974fa1437c19bceb58 100644 (file)
@@ -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
index af619fbe5be9c11325279a7f667a17870b16784c..16544295e8332bb71f882e48e05d0d3617643d61 100644 (file)
@@ -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])