From e1969d2e3f2dfd41fb0811258cd0ed51d5738dad Mon Sep 17 00:00:00 2001 From: Sam Garrett Date: Fri, 2 Jan 2015 13:06:06 -0500 Subject: [PATCH] maint - adding coveralls support --- .travis.yml | 14 ++++++++------ Makefile.am | 3 +++ README.md | 1 + configure.ac | 13 +++++++++++++ src/Makefile.am | 10 ++++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21d0547..88c0d8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ language: c before_install: -- sudo apt-get install valgrind -- ./install_deps.sh /home/travis + - sudo apt-get install valgrind + - mkdir /home/travis/deps + - ./install_deps.sh /home/travis/deps + - sudo pip install cpp-coveralls install: libtoolize && ./autogen.sh && ./configure compiler: - gcc -script: make check && make check-valgrind +script: make check env: global: - TWITC_KEY=A TWITC_SECRET=B TWITC_ACCESS_TOKEN=C TWITC_ACCESS_SECRET=D - - CFLAGS="-I/home/travis/include -L/home/travis/lib" + - CFLAGS="-I/home/travis/deps/include -L/home/travis/deps/lib" after_failure: - ls /home/travis/build/sinemetu1/twitc/src - ls /home/travis/build/sinemetu1/twitc/src/test @@ -17,5 +19,5 @@ after_failure: - cat /home/travis/build/sinemetu1/twitc/src/test/test_reply.log - cat /home/travis/build/sinemetu1/twitc/src/test/test_twitc.log after_success: - - ls /home/travis/build/sinemetu1/twitc/src - - ls /home/travis/build/sinemetu1/twitc/src/test + - make check-valgrind + - ./configure --enable-gcov && make clean coverage && coveralls -b src/ --no-gcov diff --git a/Makefile.am b/Makefile.am index 08f3d88..cd11cdc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,3 +11,6 @@ integration: check-valgrind: cd src; make check-valgrind; + +coverage: + cd src; make coverage; diff --git a/README.md b/README.md index 8c5aa4d..f439e68 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ twitc =========== [![Build Status](https://travis-ci.org/sinemetu1/twitc.svg)](https://travis-ci.org/sinemetu1/twitc) +[![Coverage Status](https://coveralls.io/repos/sinemetu1/twitc/badge.png)](https://coveralls.io/r/sinemetu1/twitc) A mini C library for interacting with the Twitter OAuth api. diff --git a/configure.ac b/configure.ac index fe7215f..c3cc293 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,19 @@ CFLAGS="$CFLAGS " CFLAGS+="-Wall -Wstrict-prototypes -Wmissing-prototypes " CFLAGS+="-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual " CFLAGS+="-Wsign-compare -Iincludes -g " + +AC_ARG_ENABLE([gcov], + AS_HELP_STRING([--enable-gcov], [enable gcov code-coverage(default=no)]), + [], + [enable_gcov=no] + ) + +AS_IF([test "x$enable_gcov" = "xyes"], + [CFLAGS+="-fprofile-arcs -ftest-coverage "], + [test "x$enable_gcov" = "xno"], [CFLAGS+=" "], + [echo "enable-gcov with wrong value"] + ) + AC_SUBST([CFLAGS]) AC_PROG_CC diff --git a/src/Makefile.am b/src/Makefile.am index c073c0d..f701593 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,5 +37,15 @@ check-valgrind: valgrind --leak-check=full --track-origins=yes test/test_twitc valgrind --leak-check=full --track-origins=yes test/test_reply +coverage: clean check + gcov twitc.c -o test_test_twitc-twitc.o -f + gcov test/test_twitc.c -o test/test_test_twitc-test_twitc.o -f + gcov twitc_reply.c -o test_test_reply-twitc_reply.o -f + gcov test/test_reply.c -o test/test_test_reply-test_reply.o -f + +clean-local: + find ./ ./test/ -type f -name "*.gc*" -exec rm {} \; + find ./test/ -type f -name "integration" -exec rm {} \; + integration: test/integration test/integration