cov.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # must be executed in project root folder
  3. # Copyright Hans Dembinski 2018-2019
  4. # Distributed under the Boost Software License, Version 1.0.
  5. # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
  6. if [ -z $GCOV ]; then
  7. # gcov-9, gcov-7, gcov-6 do not work
  8. for i in 8 5; do
  9. if test $(which gcov-$i); then
  10. GCOV=gcov-$i
  11. break;
  12. fi;
  13. done
  14. fi
  15. LCOV_VERSION="1.14"
  16. LCOV_DIR="tools/lcov-${LCOV_VERSION}"
  17. if [ ! -e $LCOV_DIR ]; then
  18. cd tools
  19. curl -L https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz | tar zxf -
  20. cd ..
  21. fi
  22. # --rc lcov_branch_coverage=1 doesn't work on travis
  23. # LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV} --rc lcov_branch_coverage=1"
  24. LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV}"
  25. # collect raw data
  26. $LCOV --base-directory `pwd` \
  27. --directory `pwd`/../../bin.v2/libs/histogram/test \
  28. --capture --output-file coverage.info
  29. # remove uninteresting entries
  30. $LCOV --extract coverage.info "*/boost/histogram/*" --output-file coverage.info
  31. if [ $CI ] || [ $1 ]; then
  32. # upload if on CI or when token is passed as argument
  33. which cpp-coveralls || echo "Error: you need to install cpp-coveralls"
  34. if [ $1 ]; then
  35. cpp-coveralls -l coverage.info -r ../.. -n -t $1
  36. else
  37. cpp-coveralls -l coverage.info -r ../.. -n
  38. fi
  39. else
  40. # otherwise generate html report
  41. $LCOV_DIR/bin/genhtml coverage.info --demangle-cpp -o coverage-report
  42. fi