Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify code coverage in CI builds #50

Closed
PeterBowman opened this issue Feb 26, 2018 · 5 comments
Closed

Simplify code coverage in CI builds #50

PeterBowman opened this issue Feb 26, 2018 · 5 comments

Comments

@PeterBowman
Copy link
Member

PeterBowman commented Feb 26, 2018

Our Travis lines for code coverage (via Coveralls) look like this (source):

install:
  # see http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/
  - if [ "$CXX" = "g++" ]; then wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz; fi
  - if [ "$CXX" = "g++" ]; then tar xf lcov_1.11.orig.tar.gz; fi
  - if [ "$CXX" = "g++" ]; then sudo make -C lcov-1.11/ install; fi
  - if [ "$CXX" = "g++" ]; then gem install coveralls-lcov; fi

after_success:
  # capture coverage info
  - if [ "$CXX" = "g++" ]; then lcov --directory . --capture --output-file coverage.info; fi
  # filter out system and test code
  - if [ "$CXX" = "g++" ]; then lcov --remove coverage.info  '/usr/*' 'tests/*' --output-file coverage.info; fi
  # debug before upload
  - if [ "$CXX" = "g++" ]; then lcov --list coverage.info; fi
  # uploads to coveralls
  - if [ "$CXX" = "g++" ]; then coveralls-lcov --source-encoding=ISO-8859-1 coverage.info; fi

Perhaps a bit too convoluted if we take a look at official docs:

Copy-paste from the latter:

language: cpp
compiler:
  - gcc
before_install:
  - pip install --user cpp-coveralls
script:
  - ./configure --enable-gcov && make && make check
after_success:
  - coveralls --exclude lib --exclude tests --gcov-options '\-lp'

More links (compiler flags et al.):

@jgvictores
Copy link
Member

Yes. That looks cleaner, clearer, and much more efficient.

@PeterBowman PeterBowman changed the title SImplify code coverage in CI builds Simplify code coverage in CI builds Mar 9, 2018
@PeterBowman
Copy link
Member Author

BTW:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")

This also sets linker flags, while the following doesn't (and makes lcov/gcov crash with undefined reference errors, see this Travis job):

add_compile_options(-fprofile-arcs -ftest-coverage)

PeterBowman added a commit to roboticslab-uc3m/speech that referenced this issue Jun 17, 2018
PeterBowman referenced this issue in roboticslab-uc3m/openrave-yarp-plugins Apr 24, 2019
Also revert a broken add_compile_options() call for code coverage.
@PeterBowman
Copy link
Member Author

Perhaps not worth the trouble if we switch to Codecov at some point: #71.

@jgvictores
Copy link
Member

jgvictores commented Sep 7, 2020

Not too sure, form a quick glance, Codecov looks different but not automatic: https://github.com/codecov/example-cpp11-cmake/blob/9c09479b7edfdc5e75f29a00e36a94394e688bdf/.travis.yml

Edit: Seeing https://docs.codecov.io/docs, maybethe "upload" step can be automatic, but all the lcov stuff seems required.

@PeterBowman
Copy link
Member Author

As part of our ongoing transition to GitHub Actions at #91, we decided to drop support for automated code coverage since we had not been using this tool anyway. In case it is deemed convenient to reinstate such support, see modern alternatives and complementary tools to Coveralls such as #71 and #68.

Marking as wontfix and closing due to obsolescence.

@PeterBowman PeterBowman closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants